nicuz Posted September 26, 2007 Share Posted September 26, 2007 I made a script that stores a picture in a database. I have 4 fields in the database: picName, picType, picSize, picture (picture is the field where the picture is actuallu stored; the other fields are self explanatory). What I want is to display the picture on my website. I have my SELECT query but when I try to display the picture using {$row['picture']} I only get a long list with letters, numbers and strange symbols. I assume that the picture is not displayed like any other text in the database so if you guys could help me I would really appreciate it. Nick Link to comment https://forums.phpfreaks.com/topic/70734-display-picture-from-the-database/ Share on other sites More sharing options...
HuggieBear Posted September 26, 2007 Share Posted September 26, 2007 Look at imagecreatefromstring() regards Huggie Link to comment https://forums.phpfreaks.com/topic/70734-display-picture-from-the-database/#findComment-355581 Share on other sites More sharing options...
nicuz Posted September 26, 2007 Author Share Posted September 26, 2007 Tried this and it did not work. I got the "An error occurred" error. $data = $row['picture']; $data = base64_decode($data); $im = imagecreatefromstring($data); if ($im !== false) { header('Content-Type: image/jpeg'); imagejpeg($im); } else { echo 'An error occurred.'; } Link to comment https://forums.phpfreaks.com/topic/70734-display-picture-from-the-database/#findComment-355589 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.