how to get the fullpath of hte file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • musammil
    New Member
    • Jun 2007
    • 1

    how to get the fullpath of hte file

    hi
    i want the fullpath of the file to be upload.
    (e.g) we are using FILE to upload files.
    in that we can get only the file name(sample.txt ) using $_FILE['userfile']['name'];
    but i want the real path of the file also (e.g C:\Program Files\Sample.tx t")
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by musammil
    hi
    i want the fullpath of the file to be upload.
    (e.g) we are using FILE to upload files.
    in that we can get only the file name(sample.txt ) using $_FILE['userfile']['name'];
    but i want the real path of the file also (e.g C:\Program Files\Sample.tx t")
    Do not post questions in the articles section.
    Moved to the forum.

    Comment

    • bonski
      New Member
      • Jun 2007
      • 53

      #3
      Originally posted by musammil
      hi
      i want the fullpath of the file to be upload.
      (e.g) we are using FILE to upload files.
      in that we can get only the file name(sample.txt ) using $_FILE['userfile']['name'];
      but i want the real path of the file also (e.g C:\Program Files\Sample.tx t")
      hi musammil,

      you can use [PHP]$_POST['form_field'][/PHP]

      this is getting the filename...
      [PHP]$_FILE['userfile']['name'][/PHP]

      and this is getting the whole path...
      [PHP]stripslashes($_ POST['userfile'])[/PHP]
      i used stripslashes() to strip extra slashes from the string...

      bonski

      Comment

      • ronnil
        Recognized Expert New Member
        • Jun 2007
        • 134

        #4
        I think it is browser-dependent if it posts only the filename or the complete path.

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          You can create a hidden input in your form that stores the value of your file input. When the User submits the form, the file path will be passed to the server as well.

          [EDIT: Ooh. Getting the $_POST value of the file input. Neat! I'll have to remember that!]

          Comment

          Working...