Sending files to the server using xmlhttp

Js:

xmlhttp.open('POST', '/or/test.php', true); xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); var data = new FormData(); var fp = $("#my_file"); for(var i=0, len=fp[0].files.length; i<len; i++) data.append(fp[0].files[i].name, fp[0].files[i]); xmlhttp.send(data); 

Interestingly, $ _FILES is empty, and $ _POST shows information about the file. Where is the mistake?

    1 answer 1

    Removed the hell header and it worked!