Hi @cwarn23 , i want ask something if you dont mind. I had look to your example code. It simple and nice

but it is useful for resizing image that will store to db as blob? I try to apply it, but not working

. Hope you can give an idea based on your experience. Appreciate your respon. Thanks in advance.
just in case, here my code
if ($submit == 'Simpan')
{
global $strDesc;
$max_size = 1000000000;
$fileUpload = $HTTP_POST_FILES['fileUpload1']['tmp_name'] ;
if($fileUpload != NULL)
{
$fileUpload_name=$HTTP_POST_FILES['fileUpload1']['name'];
$fileUpload_size=$HTTP_POST_FILES['fileUpload1']['size'];
$fileUpload_type=$HTTP_POST_FILES['fileUpload1']['type'];
$fileUpload = $HTTP_POST_FILES['fileUpload1']['tmp_name'] ;
$fileHandle=fopen($fileUpload, "rb");
$fileContent=fread($fileHandle,filesize($fileUpload));
$fileContent=addslashes($fileContent);
fclose($fileHandle);
$sqls="";
if ($fileUpload_size > (1024*1024))
{
echo "reduce";
$fileContent=resize_image($fileUpload_name,'500','500');
echo $fileContent;
$sqls = "INSERT INTO image_store (image_1,description) VALUES ('$fileContent','$fileUpload_type')";
}
else
{
echo "add biasa";
$sqls = "INSERT INTO image_store (image_1,description) VALUES ('$fileContent','$fileUpload_type')";
}
echo $sqls;
// if($sqls !="")
// $result = mysql_query($sqls);
echo '<span style="width: 600; height: 30; font-size: 20px; font-family: verdana; color: #FF0000; ">Berjaya!!!!.</span><br>';
}
}
function resize_image($filename,$newwidth,$newheight)
{
echo $filename;
if (!file_exists($filename) || !in_array(preg_replace('/(.*)[.]([^.]+)/is','$2',basename($filename)),array('png','jpg','jpeg','gif','xbm','xpm','wbmp','pjpeg')))
{
//note .wbmp is 'wireless bitmap' and not 'windows bitmap'.
echo "false";
return false;
}
else
{
echo "true";
$ext=preg_replace('/(.*)[.]([^.]+)/is','$2',basename($filename));
if ($ext=='jpg') { $ext='jpeg'; }
$ext='imagecreatefrom'.$ext;
list($width, $height) = getimagesize($filename);
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = $ext($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
return $thumb;
}
}
Hi, I have made a function that will resize images and is as follows:
<?php
function resize_image($filename,$newwidth,$newheight) {
if (!file_exists($filename) || !in_array(preg_replace('/(.*)[.]([^.]+)/is','$2',basename($filename)),array('png','jpg','jpeg','gif','xbm','xpm','wbmp'))) {
//note .wbmp is 'wireless bitmap' and not 'windows bitmap'.
return false;
} else {
$ext=preg_replace('/(.*)[.]([^.]+)/is','$2',basename($filename));
if ($ext=='jpg') { $ext='jpeg'; }
$ext='imagecreatefrom'.$ext;
list($width, $height) = getimagesize($filename);
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = $ext($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
return $thumb;
}
}
$img = resize_image('file_from.gif','320','280');
//save image to file
imagejpeg ($img,'file.gif',100);
?>
Hope that helps ya as I would imagine that some of the previous posts would be a little confusing without the syntax highlighter.