00stuff Posted October 25, 2010 Share Posted October 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/216820-php-mysql-image-to-blob-field-and-then-display/ Share on other sites More sharing options...
00stuff Posted October 25, 2010 Author Share Posted October 25, 2010 Does anyone know? Quote Link to comment https://forums.phpfreaks.com/topic/216820-php-mysql-image-to-blob-field-and-then-display/#findComment-1126410 Share on other sites More sharing options...
mentalist Posted October 25, 2010 Share Posted October 25, 2010 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... Quote Link to comment https://forums.phpfreaks.com/topic/216820-php-mysql-image-to-blob-field-and-then-display/#findComment-1126412 Share on other sites More sharing options...
00stuff Posted October 25, 2010 Author Share Posted October 25, 2010 thanks, but I don't understand what the function is doing... Quote Link to comment https://forums.phpfreaks.com/topic/216820-php-mysql-image-to-blob-field-and-then-display/#findComment-1126413 Share on other sites More sharing options...
BlueSkyIS Posted October 25, 2010 Share Posted October 25, 2010 i suggest that you do not store images in a database unless there is some good reason to do so. store the path to the image, instead, or an identifier that allows you to build the path to the image. Quote Link to comment https://forums.phpfreaks.com/topic/216820-php-mysql-image-to-blob-field-and-then-display/#findComment-1126434 Share on other sites More sharing options...
00stuff Posted October 26, 2010 Author Share Posted October 26, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/216820-php-mysql-image-to-blob-field-and-then-display/#findComment-1126450 Share on other sites More sharing options...
BlueSkyIS Posted October 26, 2010 Share Posted October 26, 2010 definitely not. store the images as images on the file system. store the image names, or some kind of name or key that is the image path. after you have more experience, this will be a no-brainer. Quote Link to comment https://forums.phpfreaks.com/topic/216820-php-mysql-image-to-blob-field-and-then-display/#findComment-1126480 Share on other sites More sharing options...
semanticnotion Posted October 26, 2010 Share Posted October 26, 2010 follow this link it may help you http://bytes.com/topic/php/insights/740327-uploading-files-into-mysql-database-using-php Quote Link to comment https://forums.phpfreaks.com/topic/216820-php-mysql-image-to-blob-field-and-then-display/#findComment-1126514 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.