【发布时间】:2014-04-02 22:19:08
【问题描述】:
我正在使用 dropzone.js 上传图片。 在上传图片之前,有一个 html 选择列表,用户需要从中选择一个类别,以便 CGI 知道将它们放在哪里。
有没有办法让 dropzone 在上传之前满足条件,或者还有其他方法?
$(function() {
Dropzone.options.myAwesomeDropzone = {
init: function () {
var myDropZone = this;
$("#btnRemoveAll").click(function () {
myDropZone.removeAllFiles();
}
);
$("#categories").change(function () {
myDropZone.removeAllFiles();
}
);
},
success: function(file,r){
file.previewElement.classList.add("dz-success");
alert(r); // response from server
// this.removeFile(file); // remove file after upload
},
drop:function(){
var tkn=getToken();
$("#token").val(tkn);
var c=$("#categories").val();
$("#cat").val(c);
},
error: function(){
ajaxError();
},
acceptedFiles: "image/jpeg"
};
});
html:
Category:<br>
<select id="categories">
<option value="foo">Please choose</option>
<option value="cat1">cat1</option>
<option value="cat2">cat2</option>
</select><br>
New category :<input type="text" id="category">
<form action="cgi/uploadfile.exe"
class="dropzone"
id="my-awesome-dropzone">
<input type="hidden" id="token" name="token">
<input type="hidden" id="cat" name="cat">
</form>
<button id="btnRemoveAll">Clear Dropzone</button>
【问题讨论】:
-
最后你是怎么解决的?我需要解决这个问题:stackoverflow.com/questions/29583625/…
标签: javascript jquery dropzone.js