use*_*914 28 javascript php dropzone.js
我使用dropzone.js作为我的拖放文件上传解决方案.我只想上传一个文件,如果我上传第二个文件,第一个应该删除,第二个应该上传.任何想法如何做到..
这是我的HTML
<form class="dropzone dz-clickable" action="upload.php" enctype='multipart/form-data'>
<i class="fa fa-cloud-upload element"></i>
<div style="color:gray;">Drag and drop or click to upload image</div>
<input type="hidden" name="filenameEmail" class="filenameEmail" value="">
<input type="hidden" name="side" value="front">
</form>
Run Code Online (Sandbox Code Playgroud)
我改变了dropzone.js
maxFiles: 1
Run Code Online (Sandbox Code Playgroud)
它只允许上传一个文件,但我不能删除以前上传的文件.请帮助我out.thanks提前
小智 77
maxFiles:1用于告诉dropzone应该只有一个文件.当有超过1个文件时,将调用maxfilesexceeded函数,超出文件作为第一个参数.
这是一个删除第一个文件预览并添加新文件的简单函数:)
maxFiles:1,
init: function() {
this.on("maxfilesexceeded", function(file) {
this.removeAllFiles();
this.addFile(file);
});
}
Run Code Online (Sandbox Code Playgroud)
dar*_*123 18
我使用maxfilesexceeded方法事件addFile和rans进入无限循环的事件调用.它应该是使用的问题,addFile因为我没有在官方网站或GitHub wiki中看到它.最后我用addedfile事件解决了.Dropzone.js是我写的最新版本(4.3.0).
init: function() {
this.on('addedfile', function(file) {
if (this.files.length > 1) {
this.removeFile(this.files[0]);
}
});
}
Run Code Online (Sandbox Code Playgroud)
dar*_*low 13
限制maxFiles为1仍允许在上载对话框中选择多个文件.要禁止在配置中选择多个映像,请指定以下init函数:
maxFiles:1,
init: function() {
this.hiddenFileInput.removeAttribute('multiple');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43052 次 |
| 最近记录: |