Don't store files/images in the database--store them on the local file system. In the database, only store file name and location (optional). Storing images/files in the database is bad practice and makes for very inefficient backups/restores.
Could you post the code you already have in to pastebin?