I wrote a script that uploads and resizes an image image, it used to work fine but the last 2 days i get an Internal Server Error. This happens to bigger images "7 mb", the smaller images like an 1 mb will work just fine. I tried to remove the scaling factor so the image won't be resize and it still won't work. I hosting on iPage and the script used to work just fine for all image sizes. Is it an error from the server size or it is an script error ? Any tips for optimising the code.
Thank you all
<?php
$id = $_POST["id"];
$page = $_POST["page"];
$target_dir = "";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadedfile = $_FILES['fileToUpload']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
$divide = 1010/$width;
$newwidth=$width*$divide;
$newheight=$height*$divide;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = $_FILES['fileToUpload']['name'];
imagejpeg($tmp,'../presentation/'.$target_file,100);
imagedestroy($src);
imagedestroy($tmp);
?>
error code :
20150218T075818: mpooutlet.com/scripts/uploadimg.php PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 22464 bytes) in /hermes/bosnaweb04a/b2659/ipg.mpooutletcom/scripts/uploadimg.php on line 13