Javascript Dropzone.js根据响应在上载后重命名文件
我正试图找到一种方法,在上传后使用dropzone.js重命名文件,这样我就可以通过发送正确的名称来删除它 我现在所拥有的:Javascript Dropzone.js根据响应在上载后重命名文件,javascript,dropzone.js,Javascript,Dropzone.js,我正试图找到一种方法,在上传后使用dropzone.js重命名文件,这样我就可以通过发送正确的名称来删除它 我现在所拥有的: this.on("success", function(file, responseText) { console.log(responseText); // responseText contains actual file name after server modifications }); addRemoveLinks: true,
this.on("success", function(file, responseText) {
console.log(responseText); // responseText contains actual file name after server modifications
});
addRemoveLinks: true,
this.on("removedfile", function(file) {
var name = file.name;
$.ajax({
type: 'POST',
url: 'delete_file.html',
data: {
'file-name': name,
},
});
});
正如您在我的ajax数据中看到的,我发送的是初始文件名,而不是服务器上的文件名(例如,如果有多个同名文件,服务器将重命名它们)。
我一直在考虑更改previewElement的成功名称:
file.previewElement.querySelector(".name").textContent = responseText;
然后在ajax中提到这一点,但它看起来不是一种优雅的方法
另一种选择是创建一个带有映射的映射,但我不确定这是否是一种过度使用
您建议上传后如何访问新文件名?我想到的最干净的选项是使用
file.xhr.response
值来保存新名称,而不是file.name
我想到的最干净的选项是使用file.xhr.response
值来保存新名称而不是文件名文件名