title: Uploading file in Selenium using sendKeys() is not working
body: <p>I am unable to upload files using <code>sendKeys()</code>. This is my code</p>
  
  <pre><code>driver.findElement(By.xpath(Locators.browseFlagIconBtn)).sendKeys("D:\\Images\\icons.png");
  </code></pre>
  
  <p>I have an input tag of type file for file upload</p>
  
  <pre><code>&lt;input type="file" id="iconFlagFile" name="iconFile" onchange="setFlagIconFile()" value="" class=" file-input-opacity" style="position: absolute; z-index: 100; font-size: 200px; line-height: 200px; top: 0px; left: 0px; opacity: 0;"&gt;
  </code></pre>
  
  <p>However when I click on submit button of the form where this input field is then I am redirected to the below page:</p>
  
  <p><a href="https://i.stack.imgur.com/ou8hx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ou8hx.png" alt="enter image description here"></a></p>
  
  <p>Cause of this issue : </p>
  
  <p>When I pass the path using <code>sendKeys()</code> then it correctly picks up the file that needs to be uploaded. However, the actual upload takes place when user clicks on the submit button. Now I don't know why it it searches for the file that it picked in Chrome's directory, for example: <code>"C:\Program Files (x86)\Google\Chrome\Application\53.0.2785.116"</code></p>
  
  <p>Obviously it will not be able to find the file.</p>
  
  <p>Question: How to fix this? Let me know if I need to provide more information.</p>