title: Fire a file input click programmatically in vanilla js via ajax (chrome)
body: <p>I've got a webapp in which any button click sends an ajax request to the server, the server validates and sends js code back to the client. The framework i am using is disallowing me to implement jQuery (it causes unpredictable problems).</p>
  
  <p>My problem is, that i have a button, that should open a file picker when clicked. And it already works in firefox and ie. To achieve this i set up a hidden file input:</p>
  
  <pre><code>&lt;input type="file" style="z-index: 999999999; visibility: hidden; position: absolute; top: 0px; left: 0px;"&gt;
  </code></pre>
  
  <p>Now, when i click the button this is what happens: </p>
  
  <ol>
  <li><p>A ajax request is send to the server, notifying it, that the button was clicked.</p></li>
  <li><p>The server knows the dynamically created IDs of the html elements, finds the right ones and answer this to the client:</p>
  
  <p><code>dropzone_[ID].inputClick();</code></p></li>
  </ol>
  
  <p>([ID] is the dynamically created ID, that only my server knows for sure)</p>
  
  <ol start="3">
  <li><p>Then, the method "inputClick()" is called on the client and performs the click on the hidden input field. The code looks like this:</p>
  
  <p>dropzone.hiddenFileInput.focus();
  dropzone.hiddenFileInput.click();</p></li>
  <li><p>Finally the file picker shows up, and i can select files properly.</p></li>
  </ol>
  
  <p>It seems to be a security issue in chrome to make it work like this. And I've already seen a lot of other people with a similar problem where focusing the input field helped, but that did not apply here.
  Also firefox and ie seem to understand that the click is a legit, delegated click via ajax, but chrome does not. </p>
  
  <p>The server communication itself has no problem. An added <code>console.log()</code> to the <code>inputClick()</code> method will always fire, on all browser, but the click event is not fired in chrome.</p>
  
  <p>Has anyone an idea how to write a workaround for this?</p>