2

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', ....................);
}
fdl
  • 107
  • 1
  • 3
  • 6
  • We cannot use PHP. This is a HTML5 application which stores the json objects in localstorage, without access to any server-side scripts. We need to send the text as a file because the files are often larger than what GET can accept – fdl Jun 18 '12 at 14:13

0 Answers0