How to upload files using HTML to website ? Does squeezing out liquid from shredded potatoes significantly reduce cook time? You have to declare data variable under method, No need of change event on file input if no any validation on change of that file. And any of this can be added to an HTML form tag via the (optional) enctype attribute: <form action="/path/to/api" method="POST" encytpe="ENCTYPE_HERE"> </form> Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. Its encoded and sent out with Content-Type multipart/form-data. Approach 2: This approach is to use XMLHTTPRequest that can directly upload the file as the content inside the body of POST request. How do I simplify/combine these two methods for finding the smallest and largest int in an array? I'm clueless right now. Why are only 2 out of the 3 boosters on Falcon Heavy reused? We can either create new FormData (form) from an HTML form, or create an object without a form at all, and then append fields with methods: formData.append (name, value) formData.append (name, blob, fileName) formData.set (name, value) generate link and share the link here. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. Approach 3: This approach is to use simpleUpload plugin. jquery - FormData to send file+data - Stack Overflow I will give this a try now @Ali Sheikhpour . How to set the default value for an HTML