title: read text from uploaded file - c# and javascript
body: <p>I have something like this:</p>
  
  <pre><code>&lt;form action="" id="fileUpload"&gt;
      &lt;input type="file" id="fileTest"/&gt;
      &lt;input type="button" id="saveFile"/&gt;   &lt;/form&gt;
  </code></pre>
  
  <p>For the user to upload a file.</p>
  
  <p>I then have this js:</p>
  
  <pre><code>$('#saveFile').click(function () {
      PageMethods.ReadFile($('#fileTest').val());
  });
  </code></pre>
  
  <p>And in my c# code i do this:</p>
  
  <pre><code>[WebMethod]
  public static void ReadFile(string path)
  {
      try
      {
          // Create an instance of StreamReader to read from a file.
          // The using statement also closes the StreamReader.
          using (StreamReader sr = new StreamReader(path))
          {
              String line;
              // Read and display lines from the file until the end of
              // the file is reached.
              while ((line = sr.ReadLine()) != null)
              {
                  Console.WriteLine(line);
              }
          }
      }
      catch (Exception e)
      {
          // Let the user know what went wrong.
          Console.WriteLine("The file could not be read:");
          Console.WriteLine(e.Message);
      }
  }
  </code></pre>
  
  <p>But the path that is sent to the webMethod is not the correct path of the file.</p>
  
  <p>I am just trying to get the data from the file and then do with it somethings.</p>
  
  <p>Is this the way to do it? If so, how can i get this to work?</p>
  
  <p>Or is there a better way of doing this.</p>
  
  <p>Thanks.</p>