[英]use dropzone.options without form
我想在ID上使用dropzone。 但是我的Dropzone.options.myid = {}無法正常工作。 如何驗證文件類型,大小
var myDropzone = new Dropzone("div#myid", { url: "/file/post"});
我不能使用標簽
console.log文件不起作用為什么? 我的來源:
<div id="myid" style="width: 500px; height: 300px; border: 1px solid black">click here</div>
JavaScript的
var myDropzone = new Dropzone(“ div#myid”,{url:“ dropzoneupload”});;
Dropzone.options.myid = {
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 2, // MB
accept: function(file, done) {
console.log(file);
if (file.name == "justinbieber.jpg") {
done("Naha, you don't.");
}
else { done(); }
}
};
我看不到您在哪里使用dropzone類定義dropzone區域,它會生成默認的dropzone嗎?
<div id="myDropZone" class="fallback dropzone" enctype="multipart/form-data">
<input type="file" id="files" class="display" multiple />
</div>
首先,您需要分離默認的放置區,然后將其添加到文檔准備加載中。
Dropzone.autoDiscover = false;
然后你jQuery或JS
var $myDropZone;
$myDropZone= new Dropzone('div#myDropZone', {*all your settings*
addRemoveLinks: true, //to remove
dictRemoveFile: '<i class="fa fa-times-circle" style="font-weight: 900;
cursor:pointer;"></i>' //I used an icon and styled as button so to give a user
experience to remove it});
希望能有所幫助,問候。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.