I have HTML form with file upload input. The form data are stored in a FormData()
object so I can send it later to the server using AJAX
.
What I’m trying to do is to access the FormData()
values so I can modify the file content itself that appear in the request for example in Web Developer Tools -> Network
.
If I’m uploading a .txt
file or image, I want to be able to read its content, modify it and re-append it to the FormData()
.
My code so far is able to show the File object but I have no clue how to access its content.
for( var pair of myFormData.entries() ){
/* pair[1] is the file object inside the FormData */
console.log(pair[0], pair[1]);
}
Thank you.