2

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.

NikiC
  • 100,734
  • 37
  • 191
  • 225
DevonDahon
  • 7,460
  • 6
  • 69
  • 114
  • This can happen due to `tmp` folder buffer size. Can you post the result of `df` in the command line? – Laerte Feb 01 '18 at 12:29
  • @Laerte I have updated my post with `df` result. However, I have the same problem both on my server and on my local installation (which is uploaded to server with git). – DevonDahon Feb 01 '18 at 12:41
  • I changed /etc/php/7.2/apache2/php.ini: file maxFilesize variable value and it worked for me – Supun Madhushanka Mar 24 '23 at 05:50

5 Answers5

1

First of all: the upload_max_filesize settings tells what maximum file size can single uploaded file have. The post_max_size however tells what is the allowed maximum size of all files (and all of post fields to be exact).

If you want to allow upload of 10 files of 10M for instance, the post_max_size should be at least 10*10 = 100M.

Also make sure you are using the right ini file. Run phpinfo() in your web browser and check the location of loaded ini files. You may be editing your CLI ini files which can be a different set of files.

By running the phpinfo() you can validate your settings are used.

Mike Doe
  • 16,349
  • 11
  • 65
  • 88
0

Set maxFilesize in dropzone options:

 <script>
      Dropzone.options.myDropzone = {
        maxFilesize: 500,
      }
</script>
Saurabh Mistry
  • 12,833
  • 5
  • 50
  • 71
  • I tried it, as mentioned in the question, unfortunately, with a figure greater then 5M, it's not taken into account and just limited to 5M. – DevonDahon Feb 01 '18 at 13:30
0

Set Limit max request body size in Apache inside VirtualHost section:

#Set Max to 20MB 
<Location />
        LimitRequestBody 20971520
    </Location>
Luigi Lopez
  • 1,037
  • 10
  • 23
0

This can happen with libraries that use Linux tmp folder to store the image to make any transformation to it, resizing for example. So, it worth trying to change the folder PHP uses to store tmp files.

To do this, you have to create a folder, for example /tmp-alt. Be sure that this folder has the appropriate permissions to store files in it. And then, go to PHP.ini, /etc/php/7.2/apache2/php.ini in your case, and change/create the following property:

upload_tmp_dir = /tmp-alt

After changing the file, restart Apache and check if uploading the file works.

Laerte
  • 7,013
  • 3
  • 32
  • 50
  • Thanks a lot for your answer, however the issue actually came from my controller where I had another option to limit uploaded file size. – DevonDahon Feb 02 '18 at 02:57
0

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'
    ]);
    ...
}
DevonDahon
  • 7,460
  • 6
  • 69
  • 114