我正在尝试重命名dropzone上的文件名,但每次向文件名添加任何内容时,插件都会停止工作。
var temp = '/file-upload';
var temp1 = '/file-delete';
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("div#gary-dropzone", {
url: temp,
addRemoveLinks: true,
acceptedFiles: ".png,.jpg,.tif,.pdf",
accept: function(file, done) {
var selected_filenames = $.map(myDropzone.files, function(selected_file) {
return (selected_file.name.replace(/\.[^.]+$/, ''));
});
// var filename = file.name.replace(/\.[^.]+$/, '')
var filename = file.name.replace(/\.[^.]+$/, '')
actuallyDelete = "YES"
if ($.inArray(filename, selected_filenames) != selected_filenames.length - 1) {
var error_msg = "Error! The File is already in Queue";
done(error_msg);
actuallyDelete = "NO"
myDropzone.removeFile(file);
} else {
done();
}
},
removedfile: function(file) {
var name = file.name;
$.ajax({
type: 'POST',
url: temp1,
data: {
id: name,
remove: actuallyDelete,
},
dataType: 'html'
});
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});
我最初的想法是传递名称以外的属性,但我无法弄清楚如何这样做。任何有关如何传递其他属性或名称更改的帮助都将受到强烈赞赏