[英]How to upload 1 file at a time with multiple selection using blueimp jquery-file-upload?
I'm using blueimp's jquery-file-upload to upload mulitple photos 我正在使用blueimp的jquery-file-upload上传多张照片
https://blueimp.github.io/jQuery-File-Upload/ https://blueimp.github.io/jQuery-File-Upload/
I've created a multiple selection input box and setup the upload script: 我创建了一个多选输入框并设置了上传脚本:
<script>
$(function () {
$("#upload_files").fileupload({
autoUpload: true,
dataType: "json",
singleFileUploads: true,
sequentialUploads: false,
url: "/photos/my_upload_script",
add: function (e, data) {
data.submit();
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$("#version_progress_bar .progress-bar").css("width",progress + "%");
},
done: function (e, data) {
if(data.result.status == "success"){
alert('well done');
}
else {
alert("it's gone pete tong!");
}
}
});
});
</script>
The problem I have, is my historic naming convention for uploaded photos. 我的问题是我上传照片的历史命名惯例。 I'm restricted in that I must use PHP's time() function.
我受到限制,因为我必须使用PHP的time()函数。 This becomes a problem when more than one photo's upload is triggered within the same second.
当在同一秒内触发多张照片的上传时,这将成为一个问题。
So, is there a way I can get jquery-file-upload to upload each photo one-by-one but still allow multiple selections in hopes that this will prevent photos uploading within the same second? 因此,有没有办法让jquery-file-upload一张一张地上传每张照片,但仍然允许进行多项选择,希望这可以防止在同一秒钟内上传照片?
I couldn't find a way to do it within the script. 我找不到在脚本中执行此操作的方法。 So, instead, I put a 1 second sleep on my ajax script.
因此,我在ajax脚本上睡了1秒钟。
is there a way I can get jquery-file-upload to upload each photo one-by-one but still allow multiple selections
有没有一种方法可以让jquery-file-upload一张一张地上传每张照片,但仍然允许多个选择
Yes. 是。 You already have the option in your code that decides this behavior:
您的代码中已经具有决定此行为的选项:
sequentialUploads: false,
Change that to true and you upload sequentially, one after another.. 将其更改为true,然后依次上传。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.