locked
Get full path file from FileUpload RRS feed

  • Question

  • User-1339422861 posted

     hi all

    i am using this code to get full path file by file upload

    SdsClerk.InsertParameters["Madark"].DefaultValue = Fu.PostedFile.FileName;

    it worked on localhost but on server the code return only file name

    how can i get full path of file

    thanks

     

    Sunday, January 2, 2011 12:13 PM

Answers

  • User-821857111 posted

    You can't.

    Some browsers provide the full file path when the upload is run locally, but others don't. No browsers provide the full path when your site is in production.



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 2, 2011 1:04 PM
  • User-158764254 posted

    you have to use javascript to obtain the full path and assign into a variable and pass on. The file name will be obtained from the upload control. 

     

    even using javascript, you'll hit a wall where most browsers simple wont divulge the full path.

    I've seen attempts like this:

        <input type="file" id="picField" onchange="preview(this)">
        <script type="text/javascript">
    
            function preview(test) {
                var source = test.value;
                alert(source);
            }
        </script>


    as mentioned earlier, IE may give you the full path but IE is the only one...

    running the above script, here are the results of selecting - c:\windows\write.exe

    IE: c:\windows\write.exe

    Firefox: write.exe

    Chrome: c:\fakepath\write.exe

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 2, 2011 3:34 PM
  • User1459534743 posted

    I don't think you can get the full path from the client-side. It's a potential security breach. Can you give us some insight on why you might need the full path of the client filesystem.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 4, 2011 6:02 AM

All replies

  • User-821857111 posted

    You can't.

    Some browsers provide the full file path when the upload is run locally, but others don't. No browsers provide the full path when your site is in production.



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 2, 2011 1:04 PM
  • User1459534743 posted

    Please clarify what you need. Do you need the path as it is on user's pc or the path where you saved the file on the server?


    Sunday, January 2, 2011 1:24 PM
  • User-1339422861 posted

    i need to get full path of file in client 

    Sunday, January 2, 2011 2:21 PM
  • User176332441 posted

    you have to use javascript to obtain the full path and assign into a variable and pass on. The file name will be obtained from the upload control. 

    Sunday, January 2, 2011 3:23 PM
  • User-158764254 posted

    what you are looking for is not something that is supported by an html fileupload although some versions of IE might give you the full path. 

    http://weblogs.asp.net/ashicmahtab/archive/2009/05/20/fileupload-control-doesn-t-give-full-path-help.aspx

    In the context of the server, the clients full path rarely has any meaning.

     

    Sunday, January 2, 2011 3:26 PM
  • User-158764254 posted

    you have to use javascript to obtain the full path and assign into a variable and pass on. The file name will be obtained from the upload control. 

     

    even using javascript, you'll hit a wall where most browsers simple wont divulge the full path.

    I've seen attempts like this:

        <input type="file" id="picField" onchange="preview(this)">
        <script type="text/javascript">
    
            function preview(test) {
                var source = test.value;
                alert(source);
            }
        </script>


    as mentioned earlier, IE may give you the full path but IE is the only one...

    running the above script, here are the results of selecting - c:\windows\write.exe

    IE: c:\windows\write.exe

    Firefox: write.exe

    Chrome: c:\fakepath\write.exe

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 2, 2011 3:34 PM
  • User-1339422861 posted

    it working on client not on server

    any idae? 

    Tuesday, January 4, 2011 4:24 AM
  • User1459534743 posted

    I don't think you can get the full path from the client-side. It's a potential security breach. Can you give us some insight on why you might need the full path of the client filesystem.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 4, 2011 6:02 AM
  • User-1339422861 posted

    i have some photo file on admin client. and the admin toll me that i dont want to save the files on server

    i  just need to save address file on database to show the file on client

    Tuesday, January 4, 2011 9:39 AM