Jump to content

PHP - MySQL - Image to blob field and then display.


00stuff

Recommended Posts

Hi guys, I have a problem. I need to create a page that has a web form to upload an image to a mySQL database and place it in a blob field. Then I need to be able to query the database later to display the image on the site. I've looked around but I just haven't found any examples that can help me. Does anyone know of any good example or can anyone please give me an example? I have nothing so far, just the html web form and database.

Link to comment
Share on other sites

Storing it and extra info is a trivial affair...

 

To get it out, say have an img tag in your html which calls a php script, which uses something like the following...

 

function dumip_it($s,$fn="fn.xml"){
   header('Content-Description: File Transfer');
   header('Content-Type: application/octet-stream');
   header('Content-Disposition: attachment; filename='.$fn);
   header('Content-Transfer-Encoding: binary');
   header('Expires: 0');
   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
   header('Pragma: public');
   header('Content-Length: '.strlen($s));
   ob_clean();
   ob_flush();
   print $s;
   exit;
}

 

Never actually got around to this, but it won't be far off...

Link to comment
Share on other sites

The site that I'm making is going to have thousands of items with pictures. Like an online store and they need to be able to be read as fast as possible and i thought that if they are included in the database in a blob field it would be easier to query and display. What do you guys think?

 

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.