Below is part of my codes...
if ($_POST['submit']) {
// connect to the database
include("db.php");
$fileNameTemp = $FILES['form_data']['tmp_name'];
$fileName = $FILES['form_data']['name'];
$fileSize = $FILES['form_data']['size'];
$fileType = $FILES['form_data']['type'];
$new_data = @fopen($fileNameTemp, "r");
$data = fread($new_data, filesize($fileNameTemp));
$src_img = ImageCreateFromString($data);
// error, image is not a valid jpg
if (!$src_img) {
die ("Sorry.It was not possible to read photo $fileName. Choose another photo in JPG format.");
}
$new_h=150;
$new_w=150;
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
if (function_exists('ImageCreate')) {
$dst_img=ImageCreate($thumb_w,$thumb_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
}
$binaryThumbnail = addslashes($dst_img);
$result=mysql_query("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) VALUES ('{$_POST['form_description']}','$binaryThumbnail','$fileName','$fileSize','$fileType')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
mysql_close();
}
I save the data as BLOB datatype
no matter what i save, it goes to 14Bytes of data (error occur; CreateImageFromString i guess). How come? im using the latest snapsnot of PHP 4.3.2...still to no avail...