Explanation
A file that has already been uploaded can be represented using a virtual file, and the unique key of the file is registered using the vindex property.
That is, deleting an existing file means deleting the virtual file.
This is the same as the "Transferring files and form data" example before, but there is a difference in that you need to pass along the deleted virtual file information at the time of the submit.
function submit(response) {
var dx = dx5.get("dext5");
document.querySelector("input[name='nfiles']").value = response || "";
// Get an array of remaining virtual files and create and register a string of the form "vindex;vindex;...vindex."
document.querySelector("input[name='ofiles']").value = dx.getItems(false).filter(function (v) { return v.type == "VIRTUAL"; }).map(function (v) { return v.vindex; }).join(";");
// Get an array of deleted virtual files and create and register a string of the form "vindex;vindex; ... vindex;."
document.querySelector("input[name='dfiles']").value = dx.getRemovedFiles().map(function (v) { return v.vindex; }).join(";");
document.querySelector("form").submit();
}
When processing the form data on the server side, it is good to handle the deleted file.
...
var dkeys = context.Request.Form["dfiles"];
if (!string.IsNullOrWhiteSpace(dkeys))
{
// In the example, we simply set whether to delete the file,
// but normally we need to delete the target file information from the associated DB file table.
}
...
if (!string.IsNullOrWhiteSpace(dkeys))
{
// The process of deleting the physical file uploaded to the real server is safe at the end of every transaction.
}
...