When trying to resize photographs I am getting the following error on my test server.

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 11520 bytes) in C:\wamp\www\phototest\reqfiles\submit_photo.req.php on line 70

here is my code from line 67 to 74

$src = ImageCreateFromJpeg($image);
$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,
    $tn_width,$tn_height,$width,$height);
header("Content-type: image/jpeg");
ImageJpeg($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);

Can anyone help? is it a problem with my code or with my server?

The quick and easy answer is that you need to figure out a different way to code that section as this shouldn't happen when you're working through your scripts.

However, often times you can fix this with a simple:

ini_set('memory_set', '16M')

On a more permanent basis, you could also increase the value of memory_set in your php.ini file, thus making the change for all of your scripts.

Again though, this just means that PHP (for some reason or another) is trying to allocate too much memory for the script it's executing. Sometimes it's not your fault if you use something like GD, since it loads all of it's information into memory.

Hope this explains.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.