Results 1 to 2 of 2

Thread: FileUpload Get the File Path

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    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.

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    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
    Last edited by KGComputers; Mar 21st, 2016 at 03:33 AM.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width