Get full path from file upload

When I use the file upload control, I just get only the file name, but I want to get the full path to the file location.

How to get the full path from a file upload control in ASP.NET?

+4
source share
4 answers

This is not possible in any browser as a security measure.

If possible, an attacker could obtain information on how files / folders were structured on a client computer.

Why do you need this information?

+6
source

You cannot receive it because the browser does not send it. It would be dangerous if browsers sent the full path to the user system.

+1
source

If you use the ASP.NET download control, on the client side you can get the full path, as shown below.

document.getElementById('UploadControl').value 

Server side

  UploadControl.PostedFile.FileName 

For more information, see the MSDN article HttpPostedFile.FileName Property .

0
source

I think you have a path to the boot control file

 HttpPostedFile httpBrowseFile = FileUpload1.PostedFile; int FileLength = httpBrowseFile.ContentLength; byte[] myData = new byte[FileLength]; httpBrowseFile.InputStream.Read(myData, 0, FileLength); FName = path + FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf('\\') + 1); 
-2
source

All Articles