1

When users upload an image to my server (Shared Server), the server shoots an error when the file has a width > 2000 pixels. It doesn't have to do with the filesize -- I can upload a 1 mb file at 2000 width and it still crashes. If I upload a 1 mb file at 1000 pixels, it works fine.

This is the error I get. Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20000 bytes)

I am using SimpleImage plugin (http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/) and CakePHP framework.

I read both PHP File Upload greater than upload_max_filesize and error and Large File Upload Errors with PHP but neither really addressed this issue.

Anyone ever come across this? Any ideas?

Community
  • 1
  • 1
Brian Weinreich
  • 7,692
  • 8
  • 35
  • 59

3 Answers3

3

you might be hitting the memory limit...

try increasing the memory_limit directive in your "php.ini"


or

add the following on the top of your php script,

ini_set('memory_limit', '128M');
Jim Jose
  • 1,319
  • 11
  • 17
  • I receive this error (sorry I didn't mention this earlier). Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20000 bytes) -- I'm on a shared server too. So, I'm guessing I won't be able to change the memory_limit. – Brian Weinreich Dec 04 '11 at 02:39
  • You can also use the php "init_set" method... edited the answer – Jim Jose Dec 04 '11 at 03:15
0

if you want to upload an image of size greater that 2000px using php store it in database . Create a table and then store the image in it using BLOB-Binary Lodge Object Use file_get_contents to get the contents of the image and then store it. Than the server won't crash

0

add this to the top of your controller that is receiving the upload

ini_set('memory_limit', '256M');

change the limit value as needed.

Jason
  • 2,035
  • 11
  • 13