FileUpload Get the File Path
Hi All,
Is there a way for me to get the original file location of the file being uploaded?
File Location: "c:\Program Files\Test Document\apple.txt"
If I'm going to use the FileUpload:
Code:
<asp:FileUpload runat="server" id="fileUpload"></asp:FileUpload>
Code Behind:
Code:
var filePath = Path.GetFullPath(fileUpload.PostedFile.FileName);
The code above gives me this path: "C:\Program Files (x86)\IIS Express\apple.txt" instead of "c:\Program Files\Test Document\apple.txt"
Thanks in advance.
Re: FileUpload Get the File Path
Hi,
Getting the file's client directory is restricted in other browsers. However using IE browsers with restrictions disabled, you can get the
file's client full path. I've tested the code and it works with Internet Explorer 10 which is installed in my workstation.
BTW, it's a bad practice to get or show the file's client path to the users.
Regards,
- kgc