Reputation: 97
When I'm using the file upload control I just get only the file name, but I want to get the full path of the file location.
How do I get the full path from the file upload control in ASP.NET?
Upvotes: 4
Views: 10394
Reputation: 65867
If you are using the ASP.NET upload control, on client side you can get the full path like the following.
document.getElementById('UploadControl').value
On the server side,
UploadControl.PostedFile.FileName
Check the MSDN article HttpPostedFile.FileName Property for more information.
Upvotes: 0
Reputation: 1455
I think you got file path of the upload control
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);
Upvotes: -2
Reputation: 15154
You cannot get it because the browser does not send it. It would be dangerous if the browsers sent the full path at user's system.
Upvotes: 1
Reputation: 498914
This is not possible in any browser, as a security measure.
If this were possible, an attacker could gain information regarding how files/folders were structured on a client computer.
Why do you need this information?
Upvotes: 6