我有一个包含dropzone.js的laravel应用程序。
上传成功
我一直在尝试使用ajax在dropzone中删除上传的文件。
在放置区预览窗格Remove file
中。
我的刀片文件。
<div class="dropzone" id="dropzoneFileUpload">
<label for="file" class="control-label text-center">Choose a file</label>
<span class="control-fileupload">
<img src="{{URL::asset('/images/image_upload.svg')}}" width="50px" class="upload-icon">
</span>
</div>
<script type="text/javascript">
var baseUrl = "{{ url('/') }}";
var token = "{{ csrf_token() }}";
var documentType = $("#RC").val();
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("div#dropzoneFileUpload", {
url: baseUrl + "/dropzone/uploadRC",
params: {
_token: token,
documentType: documentType
},
success:function(file, response)
{
//$('#documentType1').val(response['documentType']);
doctype = doctype.concat(response['documentType']);
$("#documentType").val(doctype);
doc = doc.concat(response['doc']);
$("#document").val(doc);
alert(doctype);
}
</script>
我的问题是:如何删除dropzone中的上传文件? 我没有在dropzone中看到任何选项作为ajax。
答案 0 :(得分:1)
我认为myDropzone.removeFile(file)
应该有用
success:function(file, response) {
myDropzone.removeFile(file)
}
答案 1 :(得分:1)
看 https://www.dropzonejs.com/#event-removedfile
有一个与removeFile绑定的事件。
另外,dropzone的默认功能是不启用文件删除。
将此选项设置为true将允许您在dropzone中管理文件。
https://www.dropzonejs.com/#config-addRemoveLinks。
示例:
var myDropzone = new Dropzone("#dropzone", {
url: "https://example.com",
addRemoveLinks: true,
success: function(file, response) {
// do stuff
},
removedFile: function(file) {
// remove file from server
}
});