papaface Posted January 9, 2007 Share Posted January 9, 2007 Hello,How can I show an image I have uploaded into a BLOB field in a database on a page?My code so far is:[code]<?php $grab = mysql_query("select link,comment,clicks,image from videos");(list($link,$comment,$clicks,$image) = mysql_fetch_array($grab));?>[/code]$image is the image from the BLOB field.Any help would be appreciated. regards Link to comment https://forums.phpfreaks.com/topic/33519-get-blob-from-database/ Share on other sites More sharing options...
fert Posted January 9, 2007 Share Posted January 9, 2007 you would need to have the gd functions installed[code]header("Content-type: image/img_type");$img=imagecreatefromstring($image_data);//depending on the file type you'll need to change this lineimagepng($img);imagedestroy($img);[/code] Link to comment https://forums.phpfreaks.com/topic/33519-get-blob-from-database/#findComment-156877 Share on other sites More sharing options...
papaface Posted January 9, 2007 Author Share Posted January 9, 2007 Thanks that works if i know the type of image.Is there no way of auto-detecting the image type?Also the image when displayed is named the same as the .php page. How can I fix this? Link to comment https://forums.phpfreaks.com/topic/33519-get-blob-from-database/#findComment-156881 Share on other sites More sharing options...
matto Posted January 10, 2007 Share Posted January 10, 2007 When you upload the image into the database you can record the file type at that stage - it's part of the $_FILES array[code]$_FILES['file1']['type'][/code] Link to comment https://forums.phpfreaks.com/topic/33519-get-blob-from-database/#findComment-157012 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.