admin管理员组文章数量:1404608
I want to use Dropzone.js so that the user can select images he wants to upload. But I do not want them to be uploaded on the fly, rather to just be added to form and then submitted the normal way in form array. How can I do that?
I've seen questions like How to get Dropzone.js to upload files only when a submit button is clicked?, but I do not need to upload them at all, I want Dropzone to add files to my form.
BTW, dropzone is in div, not on whole form, if it is important.
Is it possible?
I want to use Dropzone.js so that the user can select images he wants to upload. But I do not want them to be uploaded on the fly, rather to just be added to form and then submitted the normal way in form array. How can I do that?
I've seen questions like How to get Dropzone.js to upload files only when a submit button is clicked?, but I do not need to upload them at all, I want Dropzone to add files to my form.
BTW, dropzone is in div, not on whole form, if it is important.
Is it possible?
Share Improve this question edited May 23, 2017 at 12:01 CommunityBot 11 silver badge asked Dec 8, 2016 at 9:42 Paul SmallingPaul Smalling 1411 silver badge8 bronze badges1 Answer
Reset to default 5You need to set the autoQueue property to false when you initialize your dropzone instance:
var formData = new FormData();
//On addedfile:
Dropzone.options.myAwesomeDropzone = {
autoQueue: false,
init: function() {
this.on("addedfile", function(file) {
formData.append("file", file);
});
}
};
//On removedfile:
Dropzone.options.myAwesomeDropzone = {
init: function() {
this.on("removedfile", function(file) {
formData.delete('file');
});
}
};
本文标签: javascriptAdd files from Dropzone to formStack Overflow
版权声明:本文标题:javascript - Add files from Dropzone to form - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744832485a2627433.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论