Logo Questions Linux Laravel Mysql Ubuntu Git Menu

$_FILES is empty when upload in PHP

I was using the dropzone.js to handle the upload part in frontend, using JQuery.


My testing case are:

Upload a 34 MB file. Works fine...
Upload a 27 MB file. Works fine...
Upload two files, each of them is 5 MB. Works fine...
Upload two files, 34 MB + 27 MB. Fail , $_FILES is an empty array

Here is the JQuery code:

    $(document).ready(function () {
        Dropzone.options.myAwesomeDropzone = {
            autoProcessQueue: false,
            url: '<?= site_url("admin/video/upload"); ?>',
            addRemoveLinks: true,
            previewsContainer: ".dropzone-previews",
            uploadMultiple: true,
            parallelUploads: 50,
            maxFilesize: 500, //500MB
            acceptedFiles: 'video/*',
            maxFiles: 100,
            init: function () {
                var myDropzone = this;

                myDropzone.on("success", function (file, response) {
                    $("#success, #fail").hide();
                    $("#" + response).show();

                myDropzone.on("maxfilesexceeded", function (file) {

                $("#submit-all").click(function (e) {

Here is the PHP code:

public function upload() {

So, why the $_FILES is empty and how to fix it? Thanks a lot.

like image 976
user782104 Avatar asked Mar 17 '23 02:03


1 Answers

34 MB + 27 MB = 61MB.

So you would be posting 61MB.

The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size. Depending on your host, changing these two PHP variables can be done in a number of places with the most likely being php.ini or .htaccess (depending on your hosting situation)

Have you checked out these in your php.ini?

Maximum allowed size for each file uploaded.

upload_max_filesize = 40M

Must be greater than or equal to upload_max_filesize, this is the combined size of all uploaded files on each post event.

post_max_size = 40M

If you wanted to upload a max file size of 500mb than you could set both of the above value to 500mb. Remember that if you upload more than one file, the post_max_size needs to be the combined file size of the uploaded files for each post event. So if you uploaded two files of 500mb, you would set upload_max_filesize =501M and post_max_size = 1001M

like image 149
M H Avatar answered Mar 25 '23 11:03