0

For testing purpose:

According to the W3C File API specification, it's possible to create a file object:

var dynamic_file = new File(["file_content_foo"], "filename.txt");

But how to link it to the input file?

<input type="file" id="file_to_upload"/>
<input type="submit" value="post">

The goal: Sending the post will send the dynamic_file

Slake
  • 2,080
  • 3
  • 25
  • 32
  • Something like: document.getElementById('#file').value = dynamic_file; – Slake Jul 17 '18 at 01:16
  • Typical [XY Problem](http://xyproblem.info/). You want to make a POST request with a [File object](https://developer.mozilla.org/en-US/docs/Web/API/File). Instead you ask us how to attach it to an `` element. Just ask question X instead of question Y. – georgeawg Jul 30 '18 at 22:37

0 Answers0