I have successfully uploaded images into my table (store) which has three fields (id, name and image)
Image data type is blob as expected.
what I am doing wrong with the following script?
Any assistance will be gladly considered.
<?php
$host = 'localhost';
$user = 'root';
$pw = '';
$db = 'databaseimage';
mysql_connect($host,$user,$pw);
mysql_select_db($db);
$sql = "select name from store where id='1'";
$result = mysql_query($sql) or die('Bad query at 12!'.mysql_error());
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
$db_img = $row['name'];
$type = $row['ext'];
}
$db_img = base64_decode($db_img); //print_r($db_img );
$db_img = imagecreatefromstring($db_img);
if ($db_img !== false) {
switch ($type) {
case "jpg":
header("Content-Type: image/jpeg");
imagejpeg($db_img);
break;
case "gif":
header("Content-Type: image/gif");
imagegif($db_img);
break;
case "png":
header("Content-Type: image/png");
imagepng($db_img);
break;
}
}
imagedestroy($db_img);
?>
Bob Ghodsi

