title: upload image to server from javascript
body: <p>I am using the below code to view the uploaded file using javascript. It display the fake path so i can't able to upload the files to server path. please help me to upload the images to server.mappath folder.</p>
  
  <pre><code>&lt;input type='file' name='file' id='file' value='Choose Photo' accept='image/png,image/jpeg' onchange='handleFileSelect(this);' /&gt;
  
  &lt;script type="text/javascript"&gt;
  function handleFileSelect(input) {
      try {
  
          if (input.files &amp;&amp; input.files[0]) {
              var reader = new FileReader();
  
              reader.onload = function (e) {
                  document.getElementById('hf_image').value = e.target.result
                  $('#preview').attr('src', document.getElementById('hf_image').value);
              }
  
              reader.readAsDataURL(input.files[0]);
          }
  
      }
      catch (ex) {
          alert('Image Preview : ' + ex.Message);
      }
  }
  
  &lt;/script&gt;
  </code></pre>