mac03733's avatar

413 Request Entity Too Large ( when uplaoding image )

i have validation in control

$this->validate($request,[
              'member_image' => 'mimes:jpeg,jpg,png|image|max:3000'
            ]);

validation works on local ,but on sever i get 413 Request Entity Too Large error

what i hav tried:

i set upload_max_filesize in php.ini and i set client_max_body_size in nginx.conf

then i restart them , still same problem

0 likes
14 replies
munazzil's avatar

remove the this max:3000from validation and check.

munazzil's avatar
munazzil
Best Answer
Level 13

Have you tried with below with that check your all images sizes because in server storage are limited check storage setting for file also,

   http {
  client_max_body_size 20M;         
 }
1 like
mstrauss's avatar

How large is the image? You may have to take look at the post_max_size allowed on your host server's php ini file as this sets the single limit of any post request (which may include multiple files). So make sure it's at least as high as the upload_max_filesize limit you set.

rawilk's avatar

Are you sure you're editing the correct php configuration file? You can run php --ini to check.

markus.heb's avatar

Try setting also "post_max_size" equal to "upload_max_filesize" in php.ini

Usually that fixes this error for me.

mac03733's avatar

@MSTRAUSS - the image is 5MB , the post_max_size is higher than allowed. but for some reason its still not working.

mac03733's avatar

@WILK_RANDALL - i think believe so , it should be th one under

/etc/php/7.2/fpm/php.ini

if am not mistaken

mac03733's avatar

@MARKUS.HEB - i dont think thats a good idea, if u set upload_max_filesize = 2m and post_max_size = 2m, you might have a problem when u try to send a file with 2mb size and other content increasing the post size.

markus.heb's avatar

Usually I have it on 100MB so its ok for me. But you are right if it is lower, there might be a problem if the uploaded file gets near the post limit

Snapey's avatar

the file is base64 encoded in the post so expect to need 30% more max post than allowed file size

mac03733's avatar

so far my current configurations meet what you are saying, but for some reason i still keep getting 413 Request Entity Too Large

mac03733's avatar

after a bit of reading, i realised that editing the php.ini is acutally optional since the message is coming from nginx so i went back and increase to a higher value

client_max_body_size 100M;  

ill read some more and see what are suitable values.

but at-least now it makes it to controller validation

THANKS FOR YOU HELP GUYS

2 likes

Please or to participate in this conversation.