0

I am uploading and resizing images on my website and I got an

Out of memory (allocated 89391104) (tried to allocate 20736 bytes)

error. So I set memory_limit = 700M in php.ini. It worked, I could upload the whole form, but the image was not uploaded. I checked the error, it was

The uploaded file exceeds the upload_max_filesize directive in php.ini

Than I added upload_max_filesize = 50M to php.ini and now I receive the "Out of memory" error again. Any ideas why this could happen and how I can fix it?

Emlyn
  • 852
  • 6
  • 16
Lumlum
  • 103
  • 1
  • 7
  • http://stackoverflow.com/questions/4757082/upload-large-file-upto-100mb-using-php – Axalix May 17 '15 at 20:40
  • Hi @Axalix, thank you for your response. But I don't see how it can help - I've already updated post_max_size and upload_max_filesize, and as soon as I update upload_max_filesize I get "Out of memory" error again. – Lumlum May 17 '15 at 20:43
  • How large are the images you are trying to upload? are you uploading one at at a time? When processing images you must remember that for each image (i.e. original AND the resized version) the amount of memory needed will be based on the width X height and colour depth of the image (often can be much greater than the image size itself). – Ian Wood May 17 '15 at 20:53
  • Hi @IanWood, I am trying to upload 3 to 5 MB large images, one image for example has 5184 pixel x 3456 pixel, colour depth is 24. I'm resizing it to 720x500 and I'm currently uploading one at a time. – Lumlum May 17 '15 at 21:02
  • 1
    here is a very basic calculator (http://www.dotsamazing.com/en/labs/phpmemorylimit) but essentially you either have to look at managing memory (unset any variables used in image processing after each image is processed), background these processing jobs (just upload and then fork your script to process them) or upload one at a time and process. – Ian Wood May 17 '15 at 21:09
  • Thank you @IanWood very much, I've tried the calculator, it suggests 94MB. I am currently uploading only one image at a time and I don't get the Out of memory error when I only have memory_limit = 700M in my php.ini. But I get this error again as soon as I set upload_max_filesize, and I'm really confused why memory_limit = 700M "stops working". – Lumlum May 17 '15 at 21:22
  • is your file size greater than that up_load_max_filesize limit? you clearly need to look at all facets of memory usage and make sure you stay within you limits. one thing to check is if your changes on limits actually take effect - try echoing out all the settings using ini_get() – Ian Wood May 17 '15 at 21:36
  • No, the file size is not greater. I' ve currently set upload_max_filesize to 500M and my file size is < 5Mb. I've also checked my settings with phpinfo - memory_limit = 1G, post_max_size = 700M, upload_max_filesize = 500M – Lumlum May 17 '15 at 22:47

0 Answers0