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 JavaScript? According to Pre-Populate HTML form file input it seems that it is not possible due to security reasons. But I create the file in browser, this should not be the security issue.
I can probably paste the file as text to other type of input. But I do not feel that it is correct.
What is solution here? Is there way how to put file from browser to file input? Or is it ok to do it with other input? Is there a way how to pack the file to POST without input element?
The could what I would like to use:
$("#button").click(function(e) {
$('#file').val(export_pdf());
$('#form').submit();
});