If you're trying to remove files from the FileList directly, you'll run into a roadblock as it is read-only. However, there is a workaround available for deleting multiple files within the Files collection by simply setting it to an empty string:
document.getElementById('files').value = ""; //Clears all files in the input
Unfortunately, this method won't work for removing individual files.
Possible Solution
To manage file deletions more effectively, consider incorporating a hidden input element within your form to keep track of which files are marked for deletion:
<input id='filesToDelete' name='filesToDelete' runat='server' type='hidden' />
Upon deletion (presumably using JavaScript), append the filename to the filesToDelete field separated by commas:
//Within your delete Javascript method
document.getElementById('filesToDelete').value += (yourImg.title + ",");
When processing uploads on the server side, filter out uploaded files that match those listed for deletion. Store and compare these filenames using LINQ if preferred:
protected void YourUploadButton_Click(object sender, EventArgs e)
{
//Get files to be deleted
string[] filesToDelete = this.filesToDelete.Value.Split(',');
//Your collection of files
HttpFileCollection uploadFiles = Request.Files;
for (int i = 0; i < uploadFiles.Count; i++)
{
//Checks the Posted File
HttpPostedFile postedFile = uploadFiles[i];
//Avoid uploading files meant for deletion
if (!filesToDelete.Any(c => c == postedFile.FileName))
{
UploadToFTP(postedFile, i);
}
}
}
Don't forget to include a reference to LINQ at the beginning of your code-behind page:
using System.Linq;