Forum Moderators: coopster
I am trying to integrate a script into my dinamic PHP wepages, which helps to upload jpeg files by reucing the weicht, i.e. fol 1500 to 100 Ko.
The script works fine with "EasyPHP" on my laptop, but un my server I get an error message;
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 9088 bytes) in... please can sombody tell me how to increase the memory allocation
Thanks, roberto
this is my function:
function jpg_upld($ffile,$ffolder,$ffname,$ffs,$qual){
$img1=imageCreateFromJpeg($ffile);
$x1 = imageSX($img1);
$y1 = imageSY($img1);
$x2 = 600;
$y2 = (($x2 / $x1) * $y1);
$img2 = imageCreate($x2,$y2);
imageCopyResized($img2,$img1,0,0,0,0,$x2,$y2,$x1,$y1);
imagejpeg($img2,"$ffolder/$ffname",$qual);
$path=$ffolder."/".$ffname;
$ffs2=filesize($path);
$ffs2=round(($ffs2 * 0.001),0);
$ffs = round(($ffs * 0.001),0);
$perc = ((100 / $ffs) * $ffs2);
$perc = round($perc,2);
echo "<br>taille: $ffs Ko / $ffs2 Ko : $perc% de la taille originale";
imageDestroy($img1);
imageDestroy($img2);
exit();
}
Serious PHP memory management problem [webmasterworld.com]
Too CPU Intensive [webmasterworld.com]
You could always increase the memory_limit [php.net] and max_execution_time.
Well the idea is that the visitors of the site can upload images coming directly from their digital cameras (between 1 and 2 Mo) without having to work on them on Photoshop or a similar software. The images which then will be stored on the website should not ecceed 50 or 100 Ko.
The site is on a commercial hosting, so I can not interveen on the PHP settings. I am therefore looking for some possibility of having working this script. It works fine under EasyPHP on my laptop.
roberto
ini_set("memory_limit","24M"); I don't know if this works with every provider but it worked for me.
thanks to all...
roberto