I need to send file (up to few MB) generated by JavaScript to server. I need to do it with POST (not ajax POST).
How can I add file to input type=\"file\" by JavaScr
It isn't possible to create a file and attach it to an HTML form input but using the FormData object you could send a generated file to the server as part of a post request.
Pulled from the MDN:
var formData = new FormData();
// JavaScript file-like object
var content = 'hey!'; // the body of the new file...
var blob = new Blob([content], { type: "text/xml"});
formData.append("webmasterfile", blob);
var request = new XMLHttpRequest();
request.open("POST", "http://foo.com/submitform.php");
request.send(formData);
Which should get you the same result of a file generated by JS sent to the server.