title: VB.Net: How to upload a file in a <input type="file" ... >
body: <p><br>
  <p>I am trying to make a Windows Forms Program to automatically upload a file to website.<br>
  The website has a "Browse..." button from the  <code>input type="file"></code> tag, on which I <code>InvokeMember("click")</code> that triggers the file picker, but I am unable to interact with it.<p><p>
  I am not familiar with that control. I have tried with <code>SendKeys.Send("quotes.html") : SendKeys.Send(Chr(13))</code> , with no success at all. The <code>SendKeys.Send</code> commands are executed only after I manually close the file picker.</p>
  <p>Does anyone have an idea how to choose a file in this <code>&lt;input type="file"&gt;</code> control using VB.NET?</p>
  
  <p><strong>Edit #1</strong> /08.04.2015 13:00/:</p>
  
  <p><p>The web service, where I upload the files is a 3rd party application, which I cannot modify. I just want to interact with it so that my application can automatically upload the file, by interacting with the pop-up, file upload form, which appears, but I do not know how to do that.<br>
  <br>
  The part of my code for this procedure is:<br>
  <pre><code></p>
  
  <pre><code>For Each OneElement In WebBrowser1.Document.GetElementsByTagName("input")
   If OneElement.GetAttribute("type") = "file" Then
      If OneElement.GetAttribute("name") = "file[]" Then
  'Clicking the "Browse" button of the input type="file"
        OneElement.InvokeMember("click")
        'MsgBox("Here#13")
  'Trying to fill in the "FileName:" textbox of the popup form
        SendKeys.Send( _
              "strig with the file address - e.g.: C:\Folder\File.html")
  'Trying to click the open button, which is in focus
        SendKeys.Send(Chr(13))
      End If
      Exit For
    End If
  Next
  </code></pre>
  
  <p></code></pre><br>
  As mentiontioned above, the <code>SendKeys.Send</code> is executed only after the file upload pop-up is closed.<br></p>
  
  <p><strong>Edit #2: SOLVED! </strong> /14.04.2015 21:00/:</p>
  
  <p><p>The solution is to make a new thread like that:<br>
  <pre><code></p>
  
  <pre><code>...
  Dim tr As New System.Threading.Thread(AddressOf SendK)
  tr.Start()
  OneElement.InvokeMember("click")
  tr.Abort()
  ...
  Private Sub SendK()
  Threading.Thread.Sleep(2000) ' could be less
  SendKeys.SendWait("C:\TheFilePath.html") 'the file address path
  SendKeys.SendWait(Chr(13))
  End Sub
  </code></pre>
  
  <p></code></pre><br>
  For whoever whants to upgrade it, as it a raw solution:<br>
  1. May be the new thread can be associated with the onclick event of the button; <br></p>