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

2
  • Something like: document.getElementById('#file').value = dynamic_file; Commented Jul 17, 2018 at 1:16
  • Typical XY Problem. You want to make a POST request with a File object. Instead you ask us how to attach it to an <input> element. Just ask question X instead of question Y. Commented Jul 30, 2018 at 22:37

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.