Laravel 5.2 Error interacting with server 500

When I upload large images (4.2 MB) Intervention Image throws 500 errors ...

private function resizeImage($path, $imgName){ $sizes = getimagesize($path.$imgName); if($sizes[0] > $sizes[1]){ ImageManagerStatic::make($path.$imgName)->fit(920,474)->insert(public_path() . "/uploads/applications/watermark.png",'bottom-right', 30, 30)->save($path."1_".$imgName); }else{ ImageManagerStatic::make($path.$imgName)->heighten(474)->insert(public_path() . "/uploads/applications/watermark.png",'bottom-right', 30, 30)->save($path."1_".$imgName); } ImageManagerStatic::make($path.$imgName)->fit(440,226)->save($path."2_".$imgName); File::delete($path.$imgName); } 

It works for small files. upload_max_filesize=10M . When I comment on this function, it works: /

+5
source share
4 answers

I had the same problem and increasing upload_max_filesize was not enough. I also increased memory_limit to 256M and restarted the server. Then the images worked with intervention. [The above changes are in the php.ini file]

You can change upload_max_filesize and memory_limit according to the file capacity used.

+7
source

I had the same issue with the Laravel 5.1 library and Intervention Image. In my case, the problem came from the Image :: make ($ file) line, and not for loading.

I tried changing the values:

  • upload_max_filesize from 2M to 32M
  • post_max_size from 2M to 32M

Do not change anything to the error you received.

So I increase:

  • memory_limit up to 256M

He solved my problem . My hypothesis is that even if my image was about 6Mo, the image library took a lot of memory to use.

+4
source

edit your php.ini:

 upload_max_filesize = 40M post_max_size = 40M 

Your post_max_size may be less than 4 MB. Then reboot the server.

+3
source

Today I have the same problem in Laravel 5.5 when using the Intervention package to resize images in the order below:

 Image::make($image_tmp)->save($image_path); 

I do not have access to the php.ini on the server, and the server will need time to update, therefore the temporarily increased memory limit in the function itself in my Controller file, as shown below:

In ImagesController.php file: -

 public function addImage(Request $request){ // Temporarily increase memory limit to 256MB ini_set('memory_limit','256M'); $extension = Input::file('image')->getClientOriginalExtension(); $fileName = rand(111,99999).'.'.$extension; $image_path = 'images/'.$fileName; $image_tmp = Input::file('image'); Image::make($image_tmp)->resize(1182, 1506)->save($image_path); } 

Hope this helps someone in the future!

0
source

Source: https://habr.com/ru/post/1239562/


All Articles