mardi 26 septembre 2017

Laravel 5 - Allowed memory size of 134217728 bytes exhausted (tried to allocate 60067000 bytes)

This question builds on my previous question.

Basically, we upload a base64 image that is 50MB, when we have a hard limit of 10MB per image. Anything greater than 10MB should be detected before the php.ini memory limit is hit, so we can return an image is too big error to the user.

I know this would work:

ini_set('memory_limit', '-1');

But is a bad way to handle the problem. The user can send a file that's 1GB+ and my server will choke. I am looking for a solution to detect that the file is over the size limit without increasing the memory_limit, but determining it is over the 10MB limit as soon as possible so we can return a graceful error.

The solution in the previous question does not ever get reached since the memory_limit gets hit and returns the log error before anything in the controller gets to run.

Any idea how to solve this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire