1

Im making an web app for my ojt and they require me to add a delete function to a file field. Like if I choose to upload 3 of them there would be a preview to those file and I can remove some of them.

Can I just edit the fileField? Example document.getElementbyID("field").files returns a filefield Can I change that?

if not what is the best way to do it.

1 Answers1

0

Create a FormData object from your form Element and use it to handle the fields

const form = document.getElementById("your_form");
const data = new FormData(form);
data.delete("file_field_name");
Peterrabbit
  • 2,166
  • 1
  • 3
  • 19
  • i think this will delete all the file inside the file field. all of the files im talking about are in the same file field. I already sove it. tnx for the answer though – Loriel Desamito Apr 01 '22 at 07:34