简体   繁体   English

jquery文件上传在一个帖子中发送所有文件

[英]jquery file upload send all files in one post

I am using jquery file upload. 我正在使用jquery文件上传。 I use it for several pages in a project. 我在项目的几个页面中使用它。 For one project I need to upload all the files in one request because I loop trough all the images and after that, a dossier is created and closed. 对于一个项目,我需要在一个请求中上传所有文件,因为我循环遍历所有图像,然后创建并关闭一个档案。 I think it's faster to send all the images at once instead of changing the server side handler. 我认为一次发送所有图像而不是更改服务器端处理程序更快。 Only thing is, I can't get them together. 唯一的问题是,我无法将它们结合在一起。 I founded the option singleFileUploads, this works, but only if you select all the files at once. 我创建了选项singleFileUploads,这是有效的,但前提是你一次选择所有文件。 If drag and drop 2 times, it still uploads in 2 posts (and it makes 2 dossiers. 如果拖放2次,它仍会上传2个帖子(并且它会产生2个档案。

I have read the documentation ( https://github.com/blueimp/jQuery-File-Upload ), but can't find out how to get it work. 我已阅读文档( https://github.com/blueimp/jQuery-File-Upload ),但无法了解如何使其工作。 (i know that this is a plugin specially made for multiple posts) (我知道这是一个专门为多个帖子制作的插件)

So basically my question is, does anyone know how to get the inserted files before uploading so i can group them and serialize them. 所以基本上我的问题是,有没有人知道如何在上传之前获取插入的文件,所以我可以将它们分组并序列化它们。

Thnx, 日Thnx,

This post might help you: 这篇文章可能对你有帮助:

Multiple File Upload Input 多个文件上传输入

Unfortunately, it does not support IE. 不幸的是,它不支持IE。 But there is still a Flash-based plugin (free) can do that, of course it also supports multi browsers. 但是仍然有一个基于Flash的插件(免费)可以做到这一点,当然它也支持多种浏览器。

Check it out: Demos - Uploadify 看看: Demos - Uploadify

You can upload your files during form submit. 您可以在表单提交期间上传文件。

 var submitFormData = true;  
$('#fileFieldId').fileupload({
   dataType : 'json',
   autoUpload : false,
   add : function(e, imageData){
      $("#yourFormId").on("subimt",function(){
          if(sendData){
              imageData.formData = $("#yourFormId").serializeArray();              
              submitFormData = false;
          }

          imageData.submit();
      });
   },
   done: function(e,data){
       submitFormData = true;
   }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM