Search code examples
phplaravel-5dropzone.jsapache2.4debian-stretch

Dropzone : Cannot upload big images to server (>5M)


I have the following settings in /etc/php/7.2/apache2/php.ini:

max_execution_time = 300
max_file_uploads = 20
memory_limit = 32M
post_max_size = 18M
upload_max_filesize = 20M

However, if I upload a file which the size is exceed 5M, I get the message:

The given data was invalid.

And when I put Dropzone's full error response, I can also see this message:

The file may not be greater than 5000 kilobytes.

When I change Dropzone option maxFilesize, it works with figures lower than 5M, but when it's greater than 5M, the upload is still limited to 5M.

Also, I have no upload size limitation in my .htaccess file.

Where else could this problem come from ?

=== EDIT #1 ===

Below is the result of df on the server:

Filesystem     1K-blocks    Used Available Use% Mounted on
udev              989880       0    989880   0% /dev
tmpfs             200340    2884    197456   2% /run
/dev/sda1       10291200 3673732   6167924  38% /
tmpfs            1001696       0   1001696   0% /dev/shm
tmpfs               5120       0      5120   0% /run/lock
tmpfs            1001696       0   1001696   0% /sys/fs/cgroup

=== EDIT #2 ===

I made a basic upload page in my Laravel project and I was able to upload larger files (>5M), so my problem must come from Dropzone.


Solution

  • My problem came from the controller where I also have an option to set the max size.

    public function store(Request $request)
    {
        $request->validate([
        'file' => 'required|file|max:10000|mimes:' . $this->getAllowedFileTypes(),
        'attachable_id' => 'required|integer',
        'attachable_type' => 'required'
        ]);
        ...
    }