We have a form on a web page to upload files to our server:
<form enctype="multipart/form-data" action="upload_file.php" method="post">
<input type="file" name="file"><input type="submit" value="Upload">
</form>
We generate JSON objects as text in our web application, and would like to upload them to this form as if they were text files.
Is there a way to dynamically submit a text as a file to this form using javascript/jquery, e.g like this?
function UploadTextAsFile (pText) {
var filename = 'file.txt';
//post parameter pText as a text file with name "file.txt"
$.post ('upload_file.php', ....................);
}