javascript - Ajax Upload File: $_FILES is empty but files exists in request header -


i using formdata upload file when user drops files on page. works fine in client side , file details exist in request header when print_r($_files), returns empty array. no server side limit set. did test uploading file manually.

request details : https://www.dropbox.com/s/tfta4ulqlxsaism/csz.png

js code :

$('html').live('drop', function(e)     {        try         {             e.stoppropagation();             e.preventdefault();             var files = e.originalevent.datatransfer.files || e.target.file || e.datatransfer.files;             var file;             var len = files.length;             var =0;             var formdata = new formdata();             ( ; < len; i++ ) {                 file = files[i];                 if ( window.filereader ) {                     reader = new filereader();                     reader.onloadend = function (e) {                          $('html').removeclass('hover');                     };                     reader.readasdataurl(file);                 }                  if (formdata) {                     formdata.append("files[]", file);                 }                    }             if (formdata)              {                 $.ajax({                     url: base_url+"/kh/site/file/upld",                     type: "post",                     data: formdata,                     processdata: false,                     contenttype: false,                     success : function(res){                         console.log(res);                     },                     error: function(res){                         console.log(res);                     }                 });             }             return false;         }catch(a){console.log(a.message);}          }); 

php code :

<?php print_r($_files); ?> 

what missing?

thanks in advance!

i had exact same issue, , turns out not ajax fault. when comes php, upload limited not upload_max_filesize. take consideration following ini's when configuring upload params on server:

max_execution_time: if u set upload_max_filesize 100mb , script has max_execution_time of 5 sec., server return 404 or 500.

max_input_time: u want high enough in order full upload complete, depending on upload_max_filesize. internet connections nowadays have large download bandwidth, upload questionable.

post_max_size: upload process definition, $_post request, if upload_max_filesize has value of 100mb, u can't have post_max_size value lower. well, u can, when uploading, if total upload size falls between post_max_size , upload_max_filesize, $_files still empty.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -