The trouble was I was just uploading various jpegs I had scattered about my machine. The photos I was experimenting with came off my really old 2megapix Canon Ixus V and were all <300k and 1024x768.
It then occured to me that newer digicams produce much larger images and uploading 3 at a time would possibly exceed the max upload limit on our hosts PHP configuration, so I rewrote the script to handle one image at a time, and got a few images to test with from my boss's slightly newer camera which were 1600 x 1200 and 655kb.
Everytime I uploaded the image the script went to a file not found error after a long struggle. Since the page was submitting to itself this seems ridiulous. I would have expected a timeout error perhaps.
So I made a test script to upload the image, and make a smaller copy from it, then display it in the browser.
Each time I get the following error:
Code: Select all
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4800 bytes) in /home/fhlinux202/i/ib3.co.uk/user/htdocs/alltask/admin/test.php on line 10The entire script is as follows:
Code: Select all
$imagetmp = $_FILES['pic1']['tmp_name'];
$new_width = 150;
list($width, $height, $type, $attr) = getimagesize($imagetmp);
$tempImage = imagecreatefromjpeg($imagetmp);
$new_height = round($height/($width/$new_width));
// Resample
$newImage = imagecreateTrueColor($new_width, $new_height)
or die("<B>Error: New image could not be created.</B> ");
// Do a bicubic resample
imagecopyresampled($newImage, $tempImage, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
header("Content-type: image/jpeg");
imagejpeg($newImage);Someone please tell me that I've just written a poor script and show me how to fix it!