admin管理员组

文章数量:1317579

I try to use Jasny fileupload to pass multiple files to php inside of a form, which on submit event should be uploaded via ajax posted datas. But I can't get it to work. I can not append jasny uploads to posted datas.

If there is a better workaround what would be better to implement instead jasny I would like to know about.

I init my upload fields as follows

jQuery('.fileupload').fileupload({});

I try to catch theme on submit

wizard.on("submit", function(wizard) {
    jQuery.ajax({
      //here When I serialize the form I do not get the files
    });
});

I try to use Jasny fileupload to pass multiple files to php inside of a form, which on submit event should be uploaded via ajax posted datas. But I can't get it to work. I can not append jasny uploads to posted datas.

If there is a better workaround what would be better to implement instead jasny I would like to know about.

I init my upload fields as follows

jQuery('.fileupload').fileupload({});

I try to catch theme on submit

wizard.on("submit", function(wizard) {
    jQuery.ajax({
      //here When I serialize the form I do not get the files
    });
});
Share Improve this question edited Mar 14, 2014 at 18:41 Agustin Lopez 1,3654 gold badges18 silver badges35 bronze badges asked Dec 27, 2013 at 11:00 fefefefe 9,06530 gold badges111 silver badges191 bronze badges 3
  • 2 It would be helpful if you set up a jsfiddle or similar showing more of your code. – Nico Commented Mar 11, 2014 at 21:04
  • sorry I will try to refresh this issue. At that time I choose another workaround – fefe Commented Mar 13, 2014 at 20:51
  • how does your form look like? Do you have proper enctype? – Gogol Commented Mar 14, 2014 at 10:48
Add a ment  | 

3 Answers 3

Reset to default 7 +100

Try with

var data = new FormData();
jQuery.each($('#file')[0].files, function(i, file) {
  data.append('file-'+i, file);
});

So now you have a FormData object, ready to be sent along with the XMLHttpRequest.

$.ajax({
   url: 'php/upload.php',
   data: data,
   cache: false,
   contentType: false,
   processData: false,
   type: 'POST',
   success: function(data){
      alert(data);
   }
});

Please look at jQuery File Upload (https://github./blueimp/jQuery-File-Upload), it's support multiple files uploading and have backend implemented for PHP.

Let's go
1st you need put the multiple at your input file 2sd
you will need use the canvas and sent one by one at an loop in your script
give one look at https://plugins.jquery./tag/canvas/
http://canvasquery./

本文标签: javascriptJasny multiple file upload with other form elementsStack Overflow