title: Programmatically set the value of a type="file" input HTML element?
body: <blockquote>
    <p><strong>Note:</strong></p>
    
    <p>The answer(s) below reflect the state of legacy browsers in 2009. Now you can actually set the value of the file input element dynamically/programatically using JavaScript in 2017.</p>
    
    <p>See the answer in this question for details as well as a demo:<br><a href="https://stackoverflow.com/q/47515232/584192">How to set file input value programatically (i.e.: when drag-dropping files)?</a></p>
  </blockquote>
  
  <p>What I need to do is to programmatically send a POST request to a service from javascript code from an application that uses a .NET <code>WebBrowser</code>, which is basically an embedded Internet Explorer. This service requires one of the fields to be a "file". </p>
  
  <p>So either, is there any way to set the value of a "file" input in a form, given that I have <strong>the content</strong> of the file, such as in an array of bytes (and not the path of the file; I'm not trying to steal files from users here :) ). </p>
  
  <p>Or perhaps a way to explicitly create and send the POST request instead of creating a FORM dynamically?</p>
  
  <p>I need to use JavaScript code that will be run in my <code>WebBrowser</code> (think IE). Is this possible?</p>