[英]jQuery file upload not working with autoupload
I am using jQuery file upload plugin to upload my files. 我正在使用jQuery文件上传插件来上传我的文件。
My code is: 我的代码是:
$('#image').fileupload({
singleFileUploads : true,
acceptFileTypes : /(\.|\/)(gif|jpe?g|png)$/i,
autoUpload : false,
maxFileSize : 1000000,
});
When I set autoupload to true, its working as expected. 当我将autoupload设置为true时,它会按预期工作。 But when I set it to false and I want to upload file manually with submit button, it is not working and the image field has no image attached.
但是,当我将其设置为false并希望使用“提交”按钮手动上传文件时,它不起作用,并且“图像”字段中没有附加图像。
I have used the following JavaScript: 我使用了以下JavaScript:
<script src="/scripts/fileUpload/jquery.ui.widget.js"></script>
<script src="/scripts/fileUpload/jquery.iframe-transport.js"></script>
<script src="/scripts/fileUpload/jquery.fileupload.js"></script>
<script src="/scripts/fileUpload/jquery.fileupload-ui.js"></script>
<script src="/scripts/fileUpload/jquery.fileupload-process.js"></script>
<script src="/scripts/fileUpload/jquery.fileupload-validate.js"></script>
Can any one kindly tell me what's wrong here? 有人可以告诉我这是怎么回事吗?
To upload your file when you click on a button: 要在单击按钮时上传文件:
$('input').fileupload({
autoUpload: false,
add: function (e, data) {
$("button").click(function () {
$("p").html("Requête envoyée");
data.submit();
})
},
done: function (e, data) {
$("p").append("Upload terminé");
},
});
With following HTML : 使用以下HTML:
<input type="file" data-url="/echo/json" />
<button>Download</button>
<p></p>
Tested on Chrome 31, IE11 and Firefox 25 : http://jsfiddle.net/Fractaliste/MEA58/1/ 已在Chrome 31,IE11和Firefox 25上进行过测试: http : //jsfiddle.net/Fractaliste/MEA58/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.