I think you need to base64_encode and base64_decode the data going in and out of the db to make sure there are no nasty characters. Also you need to give the correct headers - which it looks like your doing. The size of the file you are storing may also exceed the packet size of the database, which has caused me problems in the past. See: http://dev.mysql.com/doc/mysql/en/packet-too-large.html On a slightly different note, storing images in your db will slow it down. What I tend to do is store images on the filesystem and then store the filename of the image in the database. To make things even quicker store no more than 10 images per folder - the can be easily achieved by using the filename eg /images/826575/6.jpg store as /images/82/65/75/6.jpg
"I think you need to base64_encode and base64_decode the data going in and out of the db to make sure there are no nasty characters." I did that but when i download my report it still has some small errors, it works but with errors =|