【发布时间】:2020-07-28 08:38:13
【问题描述】:
我正在想办法在上传后使用 dropzone.js 重命名文件,这样我以后可以通过发送正确的名称来删除它。
我现在拥有的:
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 中引用这个,但它看起来不像是一种优雅的方法。
另一种选择是创建一个带有
您如何建议在上传后访问新文件名?
【问题讨论】: