degressor
degressor

Reputation: 3

Ajax file upload with formData fails on some files

file upload with jQuery+formData and php works fine with some files. But on other, I think larger files it seems the file is cuted or something. The $_POST and $_FILES arrays are empty. I tried lot of things, but nothing helps.

Here the form:

    <form id="myform"  method ="post" enctype="multipart/form-data">
       <input type="file" id="file-documents" name="file" class="hidden">
    </form>

and js code:

        var form = $('#myform')[0];
        var data = new FormData(form);
        data.append('job', 'upload_file');

     $.ajax({
        url: 'api.php',
        type: 'POST',
        data: data,
        async: false,
        cache: false,
        processData: false, // Don't process the files
        contentType: false, // 
        success: function(data) {
            ...
        }
    });

I see following in the firebug request:

Source -----------------------------15933312197684 Content-Disposition: form-data; name="file"; filename="ganz alt.zip" Content-Type: application/x-zip-compressed

PK����êPEëøz ýtQ�ù¥X����20140728164446766.pdfÄZù_×PÍ!âÆ�AÙTG¥dµJÀ²FÔ¥-¶QÁAÐÙJ ì"­ ®EQµ `­U|¶}ïÄ÷þ÷î½sï9ç~Ï÷|ÏØùø9»¬\£o[V­ïfµÚjL¢þÆ«"¾J[½%&1Kê¯ÚÆ!5Rö~§¿j{B,oµf« þÿ¸/âI+·µëÖé¯b%ÂâûSR÷óâx¤þbòþÛR÷rãVùÄNàÆm>¸÷+ýU~ ÉdÜAÎ*ðÛæÇÝ·KÕ Û{0ågãFÍt~

...

-----------------------------15933312197684 Content-Disposition: form-data; name="job"

upload_file -----------------------------15933312197684--

Upvotes: 0

Views: 877

Answers (1)

Kyle
Kyle

Reputation: 1733

You need to increase your max post file size. Open up your php.ini file and find the variables post_max_size = 8M and upload_max_filesize = 2M. Change the values to 16M or however large you need. Be careful not to make it any larger than you really need to though.

Upvotes: 2

Related Questions