【发布时间】:2021-07-18 13:51:30
【问题描述】:
我有一个表单,其中包含我使用 DropZone 库提交的文章信息和图像。 我对这个库没有任何问题,它工作得很好,但是当提交的表单有错误并且我通过 Ajax 在客户端收到此错误消息时,用户修复了问题并再次发送表单,但不幸的是表单是没有发送,也没有留下任何文件。未选中的 虽然文件在预览中可用并且只发送到服务器一次。 我应该怎么做才能解决这个问题? 请输入简单的代码。 谢谢
成功多重功能
myDropzone.on("successmultiple", function(file,serverResponse) {
/* None of the uploaded files are available in Drop Zone here anymore,
** and I had to delete the files so the user could choose again,
** which would not be a good user experience.
** Exactly what code should I write here so that there is no need to
** re-select files from the user's system?
*/
myDropzone.removeFile(file);
if(serverResponse.status)
{
// Success:: In this case, I have no problem
alert("Article saved successfully. Redirecting to the Articles page ...");
window.location.href = serverResponse.redirectedTo;
}
else
{
// Display errors received from the server to the user
alert("Please enter your name and resubmit the form.");
}
});
【问题讨论】:
标签: javascript forms file-upload dropzone.js dropzone