我有以下形式:悬浮窗:未捕获的错误:没有提供网址
<form class="block-center" id="pdfForm" method="POST" action="form_threatment.php" enctype="multipart/form-data" style="margin-top: 30px;">
<div class="form-group push-50-t col-md-12">
<div class="col-md-12">
<div class="form-material form-material-primary">
<div class="dropzone dropzone-previews" id="pdfFile">
</div>
</div>
</div>
</div>
</div>
<div class="form-group push-50-t col-md-6">
<div class="col-md-12">
<div class="form-material form-material-primary">
<input class="form-control" name="first_name" type="text" id="first_name" />
<label for="first_name"><span class="asterix">*</span> Prénom : </label>
</div>
</div>
</div>
我有这样的dropzone.js库:
<script src="assets/js/dropzone.js"></script>
和我自己的悬浮窗myDropzone.js:
<script src="assets/js/myDropzone.js"></script>
在myDropzone.js
文件中我已经配置了div#pdfFile这种方式:
Dropzone.autoDiscover = false;
$(document).ready(function() {
Dropzone.options.pdfFile = {
// url does not has to be written if we have wrote action in the form tag but i have mentioned here just for convenience sake
url: 'form_threatment.php',
acceptedFiles: '.pdf',
maxFilesize: 20,
addRemoveLinks: true,
autoProcessQueue: false, // this is important as you dont want form to be submitted unless you have clicked the submit button
uploadMultiple: false,
autoDiscover: false,
paramName: 'pdf', // this is optional Like this one will get accessed in php by writing $_FILE['pic'] // if you dont specify it then by default it taked 'file' as paramName eg: $_FILE['file']
previewsContainer: '#pdfFile', // we specify on which div id we must show the files
clickable: false, // this tells that the dropzone will not be clickable . we have to do it because v dont want the whole form to be clickable
accept: function(file, done) {
console.log("uploaded");
done();
},
error: function(file, msg){
alert(msg);
},
init: function() {
var myDropzone = this;
// #submit-all it the id of the submit button
$("#submit-all").on("click", function(e) {
var files = $('#pdfFile').get(0).dropzone.getAcceptedFiles();
console.log(myDropzone);
console.log(files);
//e.preventDefault();
//e.stopPropagation();
myDropzone.processQueue(); // this will submit your form to the specified action path
// after this, your whole form will get submitted with all the inputs + your files and the php code will remain as usual
//REMEMBER you DON'T have to call ajax or anything by yourself, dropzone will take care of that
});
}
};
Dropzone.options.pdfFile.init();
});
当加载页面时,我得到的错误:
Uncaught Error: No URL provided.
早些时候,我已经修改了dropzone.js文件来设置悬浮窗的选择,但我重置dropzone.js库文件并决定在myDropzone.js文件中设置选项。
当选项分别设立在dropzone.js文件,我没有错误,但我在myDropzone.js复位后这些,和设置他们,我有这个错误,这使我相信的选项未初始化在myDropzone.js。
事实是,当我点击#提交全部按钮时,init()函数可以正常工作。
有关如何解决问题的任何想法吗?通过删除它
Uncaught Error: No URL provided.
:
好吧,我解决了。
现在,当我提出,我得到以下错误:
Uncaught TypeError: myDropzone.processQueue is not a function
在init()函数。
编辑:
我解决了前次的错误,通过删除processQueue功能,并阻止我的上传页面验证按钮,直到PDF尚未成功地上传。 我知道这是一个丑陋的黑客,但我没有找到另一种方式来做到这一点。
'未捕获的错误:未提供网址' - 是否显示此错误所在的代码行? –
它在dropzone.js的第440行上引出:'if(!this.options.url){{0} {0} {0} {0}抛出新的错误(“No URL provided。”); }' 这是在dropzone.js库的函数'function Dropzone(element,options)'中。 我应该在** dropzone.js **之前导入** myDropzone.js **吗? –
绝对不会颠倒这两个文件的顺序 - 你当然似乎没有设置任何'options.url',所以它的原因你得到那个错误 –