Jump to content

PHP / MySQL downloading BLOBs


Snaptea

Recommended Posts

Hey everyone,

 

I am trying to use BLOBs to upload files to our site. (In the past I always thought it was easier to just upload the file directly to the server and link to it via the database, but we have a security expert that has told us it is more secure to do it via BLOBs). We will also be using a free tool that scans each file for Malware but we aren't there yet...

 

I am able to upload the files into the MySQL Database but I cannot output the data. I do not need to display the information on the screen, all I need is a link so that the user can download the information. The problem is that the output is a bunch of encrypted information is seems like. I have attached the screenshot below as an example of a .gif.

 

The first few lines are the ID, File Size, File Type, File Name, and finally the long string of Final Content.

 

If anyone can help me figure this out it would be great.

post-134107-13482403544922_thumb.png

Link to comment
Share on other sites

The data is showing properly in the database. A BLOB is a Binary Object, so it will not be human readable. All you have to do to display it is set the header to the proper type, and echo the contents of the retrieved field. Don't output anything else, just the contents of that field.

 

Here is an example that stores and outputs a BLOB stored in MySQL: http://www.anyexample.com/programming/php/php_mysql_example__image_gallery_(blob_storage).xml

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.