Hi guys
This is how I am storing an image to database
Now I want to upload the resized image to my server, instead of the database. Question is, what should be uploaded?PHP Code:$allowed_typesz = array("image/jpg", "image/jpeg", "image/pjpeg", "image/png", "image/x-png");
$uploadfilez=$_FILES['auth_img']['tmp_name'];
$uploadnamez=$_FILES['auth_img']['name'];
$uploadtypez=$_FILES['auth_img']['type'];
if(!in_array($uploadtypez, $allowed_typesz)) {
print '<p> </p><p> </p><div class="mybutton2">
<font color="red">'.$whatphoto.'<br /><br />
'.$please.' <a href="javascript: history.go(-1)">'.$goback.'</a> '.$whatphoto1.'</font></div>';
include 'include/bottom.php';
exit();
}
// RESIZE IMAGE TO BETTER DIMENSIONS AND SIZE
$src = ImageCreateFromString(file_get_contents($uploadfilez)); // bitmap image works with all image types
$new_width = 300; // set max limit for width for new image
$new_height = 300; // set max limit for height for new image
$old_width = ImageSx($src); //find width of old file
$old_height = ImageSy($src); //find height of old file
if (($old_height > $new_height)||($old_width > $new_width)) {
if ($old_height > $old_width)
{ $new_width = round(($new_height / $old_height) * $old_width); }
if ($old_width > $old_height)
{ $new_height = round(($new_width / $old_width) * $old_height); }
} else
{ $new_width = $old_width;
$new_height = $old_height;
}
$dst = ImageCreateTrueColor($new_width,$new_height); //create new image
ImageCopyResampled($dst, $src,0,0,0,0,$new_width,$new_height,$old_width,$old_height); // copy old image into new image resized
Imagedestroy($src);
$quality = 75 ; //new file quality scale 0-100 (100 best)
ob_start();
if ($uploadtypez=='image/gif')
{Imagegif($dst, $uploadfile);}
elseif ($uploadtypez=='image/png')
{Imagepng($dst, $uploadfilez);} else {
Imagejpeg($dst, '', $quality); }
$filedataz = ob_get_clean();
Imagedestroy($dst);
/////////////////////////////////////////////////////////////
$uploadsizez = strlen($filedataz);
$img_height=$new_height;
$img_width=$new_width;
$filedataz=addslashes($filedataz);
Had the resizing script were not present, I could simply upload $uploadfilez to the server. Or, I can upload $filedataz to a mysql base, after resizing.
What should I upload to the server after resizing?
Thanks for your time.






Bookmarks