Upload failed when upload size is greater than 2MB in laravel and Vue

Upload failed with laravel when upload size is greater than 2MB

Problem Scenario

I got into strange problem this weekend.

While developing one of the client's CMS with upload facility, i was unable to upload file with the size greater than 2MB.

I was using Laravel 5.7 as backend and Vue as frontend

Development Tools

List of Development environment over me

Laravel 5.7 Vue 2

Phpstorm Php 7.2

Valet-linux

Explanation

First on place when getting this error,I was sure that it was do to with php configuration, so i had tried changing

upload_max_filesize

post_max_size

which was located on /etc/php/7.2/fpm/php.ini I changed them then restarted the valet using valet restart with πŸ™

But same old problem. 😬

Then, i searched all over internet but found nothing helpful. I thought it is because of Vue upload(simple)(frontend) then i also changed the upload plugin with Vue Dropzone. Tried once more again with πŸ™ Since it first tried with same sample from Dropzone.

        dropzoneOptions: {
                  url: 'https://httpbin.org/post',
                  thumbnailWidth: 150,
                  maxFilesize: 0.5,
                  headers: { "My-Awesome-Header": "header value" }
              }

It works even if file is greater than 2MB But as soon as it changed to which was my laravel endpoint for uploading file

        dropzoneOptions: {
                            url: process.env.BASE_API+'site/upload',
                            thumbnailWidth: 150,
                            maxFilesize: 10,
                            headers: { 
                                'Authorization': `Bearer ${Vue.auth.getToken()}` 
                            }
                        }

Afterward grrr.. same old problem

If file is less than 2MB , it works πŸ˜„

else it fails 😠

But This has shown that it was problem with my own Laravel or php configuration.

I have written long story so that it might be helpful on how to identify the problem.

Solution

Finally After so many attempt, i some how managed to solve this problem. And we feel so stupid when we found solution was so easy yet we could not find it.

On the terminal i looked for php configuration

    php --ini

Php configuration

The php ini file was loaded from /etc/php/7.2/cli/php.ini

but we always tried with /etc/php/7.2/fpm/php.ini then bangled our head looking solution outside.

Same old process i changed

upload_max_filesize

post_max_size

which was located on /etc/php/7.2/cli/php.ini then restarted the valet using valet restart

Now happy forever ☺️

Upload success

Share With