Skip to content
Advertisement

how do I post form data and upload file with the JS fetch API

I am trying to post form data using JS fetch API, also i successfully send data and get response , but got an error in file uploaded my file is not uploaded , and also not get stored filename into database.

JavaScript

And javascript code

JavaScript

Advertisement

Answer

No need to transform to JSON, and no need to use entries() on FormData. Also check the spelling, you wrote formdata which is different than formData.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement