0

I am tryiong to upload a picture to my laravel 6.11.0 project and the limit is 2MB. How can I increase this value ?

here is the function

 public function storeProductPic() {
        $data = request()->validate([
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg'
        ]);
        //uploading the image
        $imageName = time().'.'.request()->image->getClientOriginalExtension();
        request()->image->move(public_path('images'), $imageName);
        $productPic = new ProductPic();
        $productPic->link = "/images/".$imageName;
        $productPic->save();
        return back();
    }

2 Answers2

3

Try increase your upload_max_filesize

first way :

You can increase with php ini_set : http://php.net/manual/en/ini.list.php ex :

ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');

second way :

via .htaccess, make sure your web server allow .htaccess rewrite

php_value upload_max_filesize 40M
php_value post_max_size 42M

third way :

set the value of upload_max_filesize and post_max_size in your php.ini, then restart your web server :

; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
0

You can edit this kind of setting from php.ini. Please change value of upload_max_filesize. It will allow you to change the maximal limit of upload file size.

FYI: After modifying php.ini file, you need to restart your server.

Sahil Gupta
  • 578
  • 5
  • 16