i am experiencing strange problem while trying to upload images into mysql LONGBLOB field.. only 255 characters are getting stored and displayed and hence, image is not displayed..
Following is code which i am using for storing icon..
- Code: Select all
echo 'Updating Icon..<br/>';
$fname = $_FILES['icon']['tmp_name'];
$ftype = $_FILES['icon']['type'];
$fsize = $_FILES['icon']['size'];
$fp = fopen($fname, 'rb');
$data = addslashes(fread($fp, $fsize));
fclose($fp);
mysql_query("update mytable set icontype = '" . $ftype . "', icon = '" . $data . "' where entity = 'myentity';", $con);
if (mysql_errno())
die (mysql_error());
unlink($fname);
Following is the code i am using for displaying LONGBLOB
- Code: Select all
$iconResult = mysql_query("select icon, icontype from mytable where entity= 'myentity';");
$iconRow = mysql_fetch_assoc($iconResult);
header('Content-Type: ' . $iconRow['icontype'] . "\n");
//header('Content-length: ' . strlen($iconRow['icon']) . "\n");
print $iconRow['icon'];
please tell me what mistake i am making, and how to fix this problem..
thanks alot..