Why not attach the file?

Faced with such a problem trying to submit the form with the file that way
function sendForm(form, callback) {
 xhr = getXMLHttp();
 var url = $(form).attr('action'); 
 var formdata = new FormData(form); 
 xhr.open('POST', url, true);

the form is sent so onsubmit="sendForm(this, false); return false;"
the file thus is not attached, come in only text form fields, if remove return false;, open the page on which the file is sent, and so you can see the file you upload...
March 23rd 20 at 19:38
1 answer
March 23rd 20 at 19:40
In the attributes of the <form> add: enctype='multipart/form-data'

Find more questions by tags jQueryJavaScript