Hello,
I am having problems using your code. I needed to change it to work in my situation, and I'm afraid I may have messed something up.
I have a MySQL database running with a 'files' table. It has a 'file_id', 'file_name', 'file_size', and 'file'. 'file' is the BLOB (mediumblob) column...