jQuery文件上传在一个帖子中发送所有文件 [英] jquery file upload send all files in one post
问题描述
我正在使用jquery文件上传.我将其用于项目中的多个页面.对于一个项目,我需要在一个请求中上传所有文件,因为我循环浏览所有图像,然后创建并关闭一个档案.我认为一次发送所有图像比更改服务器端处理程序更快.唯一的事情是,我无法将他们聚在一起.我创建了singleFileUploads选项,此方法有效,但前提是您一次选择所有文件.如果拖放2次,它仍会上传2个帖子(并且会生成2个文档.
I am using jquery file upload. 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. If drag and drop 2 times, it still uploads in 2 posts (and it makes 2 dossiers.
我已经阅读了文档( https://github.com/blueimp/jQuery-File -上传),但找不到如何使它正常工作的信息. (我知道这是专门为多个帖子制作的插件)
I have read the documentation (https://github.com/blueimp/jQuery-File-Upload), but can't find out how to get it work. (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,
推荐答案
您可以在提交表单期间上传文件.
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;
}
});
这篇关于jQuery文件上传在一个帖子中发送所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!