Dear All
i try to store image into BLOB field in Image table in mysql DB and i use script below...
when i try to check it said that all thing is OK and Img stored but when i try to read it from DB i can't... i check its size in DB i find it is only 135 Byte also the real size of photo is 4989 Byte...
So i think i've prolem in storing process.... plz c code below and try to Guid me to the error
<?
include_once ("$DOCUMENT_ROOT/inc/global_functions.inc.php");
include_once ("$DOCUMENT_ROOT/connections/db.php");
$W='120';
$H='140';
$Img=$HTTP_POST_VARS['img_n'];
//echo "img var".$img_n;
/*if(!isset($img_n)){
echo "error, no file";
}
*/
if(!is_uploaded_file($img_n)){
echo "your IP has been Locked";
exit();
}
$ImgName=$_FILES['img_n']['name']; //echo 'IMG is : '.$ImgName;
$ImgType=$_FILES['img_n']['type'];// Image Type,One Of: image/gif, image/jpeg, image/jpg image/pjpeg
$ImgSize=$_FILES['img_n']['size'];// Image Size
$ImgTempName=$_FILES['img_n']['tmp_name']; // Image Temp Name
$ErrorCode=$_FILES['img_n']['error']; // Error Code
echo 'file name '.$ImgName.'<br>';
echo 'Type '.$ImgType.'<br>';
echo 'file temp name '.$ImgTempName.'<br>';
echo 'Error '.$ErrorCode.'<br>';
echo 'Size '.$ImgSize.'<br>';
$ImgDim=getimagesize($ImgTempName);
echo 'Image Dim is: '.$ImgDim.'<br>';
$ImgW=$ImgDim[0]; echo $ImgW."<br>"; // Uploaded Image Width
$ImgH=$ImgDim[1]; echo $ImgH."<br>";// Uploaded Image Height
///////////////////////////////////////////////////////////////////////
// Processing Image with our Constants
// Checking image type
if(($ImgType!="image/gif")&& ($ImgType!="image/jpg")&&($ImgType!="image/pjpeg")){
echo "You try to upload img with unvalid formt, please sure to be gif or jpg<br>";
exit();
}
// Checking Dimensions
if($ImgW<>$W){
echo "the Width of your photo is not valid, it must be <B>$W</B> Pixcel<br>";
}
if($ImgH<>$H){
echo "the Height of your photo is not valid, it must be <B>$H</B> Pixcel<br>";
}
$ImgHandel=fopen($ImgTempName,'r');
$BinaryImg=fread($ImgHandel,$ImgSize);
echo $BinaryImg."<br>";
$res=mysql_query("insert into images(img)values('$BinaryImg')");
echo mysql_error();
if ($res) echo "IMG Inserted...<br>";
fclose($ImgHandel);
?>