0

I am using HTML input file to select the file. I have tried in JQUERY but I it returns fake path.

$("#inputfile").val()

I want to get selected file actual path e.g

D:\Documents\image.png

So I have tried to upload the file in ASP.NET MVC and check the path but It also gives file name.

[HttpPost]
public ActionResult GetFileName() {
    var result = "";

    if (Request.Files.Count > 0)
    {
        result = Request.Files[0].FileName;
    }

    return Json(result);
}

Is there any solution to get the path. I know this a browser security feature but I have to entertain the client requirement. Please suggest the solution if exist.

Thank you

Shoaib Ijaz
  • 5,347
  • 12
  • 56
  • 84

1 Answers1

1

Short answer - no way.

You cannot get the client's file path, only the filename.

Backs
  • 24,430
  • 5
  • 58
  • 85
  • Actually, you can in [old versions of Internet Explorer](http://stackoverflow.com/a/20688629/636942). – Brad C Sep 08 '15 at 18:36