0

I am looking for the code that can help me in getting the original path(not fake path) of the image that has to be uploaded from the client machine.As many browsers doesn't provide the path due to some security issues.

Here is my html code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
  <script src="js\ajax_jquery_jquery-1_9_0.js" type="text/javascript"></script> 
    <script type="text/javascript" language="javascript">

      function valueCheck() {
        //alert ur fileupload control value
        var path = document.getElementById("file").value;
        //alert(document.getElementById("file").value);
        alert(" PATH " + path);
        //check for other controls value
        var icon_elem = document.getElementById("img");
        icon_elem.src = path;
        display();
                }

       function display() {
        $.ajax({    
              type: 'POST',
              url: 'xidirectorywebservice.asmx/UploadImage',
                                data: "{ }",
              contentType: 'application/json; charset=utf-8',
              dataType: 'json',
              success: function (image_string) {
                                     var data = 'data:image/png;base64,' + image_string.d;
                  var icon_elem = document.getElementById("ItemPreview");
                  icon_elem.src = data;

              },
              error: function () {
                  alert("Error");
              }
          });
      }
</script>
</head>


<body>
<br />
<img id="ItemPreview" src=""  />
<label for="file">Filename:</label>
<input type="file" name="file" id="file"/><br/>
<input type="submit" name="submit" value="Submit" onclick="valueCheck()" />

</body>
</html>

The above code has two buttons choose file which is used to choose the image from the client machine and submit button which checks the path of the image(we are getting the fake path here) as we need to pass it to the web service in order to save it in database.

After a long struggle i realized that i cannot get the path using the client side code, and have got no idea how to extract this path using vb.net web service can any one help me with this?

cheers.

pavan
  • 470
  • 3
  • 11
  • 25
  • 1
    No way, as you mentioned it's restricted for client and server/service as well – Eugene P. Feb 17 '14 at 08:24
  • C# and VB.NET? Do not put tags that are not related to your question – Steve Feb 17 '14 at 08:27
  • You can`t. http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav – heinob Feb 17 '14 at 10:11
  • Possible duplicate of [How to get full path of selected file on change of using javascript, jquery-ajax?](https://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav) – Kukeltje Jun 12 '18 at 05:49

0 Answers0