I have problems uploading pictures on my remote server (working fine locally).
The first error i got was that the file was exeeding the server limit for uploads of 2mb. Sounded fair, i was trying with a 5mb photo. Then i modified the apache2/php.ini to allow a limit of 40mb and this is the error i have now.
The problem is only with "large" images, it works fine with little ones
Laravel error log says nothing but apache2 log says
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 19008 bytes) in /var/www/ilmortaretto/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php on line 119
any suggestions for solving?
Php itself can't allocate enough memory to execute the script. Try to heighten your memory limit to 256MB in the constructor of the Lfm class with: ini_set('memory_limit','256M');
If that works you can consider allocating more memory in php.ini like you did with the upload limit.
Don't forget to restart php afterwards.
Check out this thread: https://laracasts.com/discuss/channels/servers/interventionimage-memory-limit
And this page of the php docs for more info:
http://php.net/manual/en/ini.core.php
I hope this solves your problem.
@gwleuverink thanks for your solution. I think this issue should be caused by Intervention/image. We should add this line in.
@g0110280 Thanks! I'll create a PR if @gabantonelli confirms this worked for him.
What do you think of a config variable that can either be false or a string that can be used in ini set. False being the default value so a tuned php install won't be overwritten.
@gwleuverink I think it is good not to overwrite tuned settings. But we should also make it a greater default value, since many developers won't read document and change lfm.php. Or this issue might be reopened someday.
@g0110280 That sounds good. So a default value that should be enough for this issue not to occur again and false as an optional value. Should I also include a config variable for the upload limit while i'm at it?
@gwleuverink do you mean validating uploading file size? If so, this config has already done that.
@gwleuverink i can't find exactly where you suggest to add the line. You mean in the LfmController in vendor folder?? I don't like to touch stuff there and it's in my .gitignore 馃槃
@g0110280 Sorry for not being clear, gabontonelli's first issue was with his files exceeding the php upload limit
The first error i got was that the file was exeeding the server limit for uploads of 2mb. Sounded fair, i was trying with a 5mb photo.
When we add the ini_set line for the memory limit I thought there was no reason not to also add a rule for upload_max_filesize. Since that was part of the problem also. What do you think?
@gabantonelli My bad I answered by heart. Try to put the line here
I agree that editing code in the vendor directory is a bad idea but it's just to check if it works. You can just try to edit the value in php.ini if you don't want to test it first.
it worked perfectly 馃憤
@g0110280 I started work on the extra settings. I think this should work but haven't tested it yet. Will do so tomorrow and submit a PR.
I also included the upload_max_filesize option but it seems that the upload happens before the setting is changed so it doesn't have any effect. As explained in this post. I'll remove that before submitting.
@gwleuverink understood. I will add some comments in lfm.php to inform developers about setting php.ini.
hello ! i got a fatal error .
FatalErrorException in 5c607a9f09eeb20c809d9c9825c6596cd89e0d61.php line 24: syntax error, unexpected '?'
@jackslova that is another issue. We used some php7 scripts in the code. They should be replaced to support older php versions. We will fix this in v1.7.5.
Thanks @gwleuverink for the PR, @gabantonelli please upgrade to v1.7.5 and run php artisan vendor:publish --tag=lfm_config --force.
Most helpful comment
Php itself can't allocate enough memory to execute the script. Try to heighten your memory limit to 256MB in the constructor of the Lfm class with: ini_set('memory_limit','256M');
If that works you can consider allocating more memory in php.ini like you did with the upload limit.
Don't forget to restart php afterwards.
Check out this thread: https://laracasts.com/discuss/channels/servers/interventionimage-memory-limit
And this page of the php docs for more info:
http://php.net/manual/en/ini.core.php
I hope this solves your problem.