How to send a file and parameters within the same XMLHttpRequest


To send a file and parameters within the same XMLHttpRequest:

var myForm = new FormData();

myForm.append('param1', 'demo');
myForm.append('param2', 6767);
myForm.append('myDir', 'public-data');
myForm.append('demofile', file);

xhr.send(myForm);

Updated on: 28-Jan-2020

335 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements