Retrieving full path of file on upload to php script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don

    #1

    Retrieving full path of file on upload to php script

    How do I retrieve the full path (C:\.....filena me) of a file uploaded to a php script on the server.
    I think $_FILES will only provide 'name', which is only the filename itself.

    Thanks, Don


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
  • John Dunlop

    #2
    Re: Retrieving full path of file on upload to php script

    Don wrote:
    [color=blue]
    > How do I retrieve the full path (C:\.....filena me) of a file uploaded
    > to a php script on the server.[/color]

    That information usually isn't sent. And see RFC2183 sec.
    2.3 (http://www.ietf.org/rfc/rfc2183.txt ).
    [color=blue]
    > I think $_FILES will only provide 'name', which is only the filename
    > itself.[/color]

    But $_FILES['foo']['name'] will be empty if no filename is
    given to the server. Although they 'should attempt to
    supply a file name for each submitted file' (HTML4.01 sec.
    17.3.4), user agents are not required to supply them.

    HAGW!

    --
    Jock

    Comment

    • Theo

      #3
      Re: Retrieving full path of file on upload to php script

      John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in
      news:MPG.1be43c af7f342d4198979 0@News.Individu al.NET:
      [color=blue]
      > Don wrote:
      >[color=green]
      >> How do I retrieve the full path (C:\.....filena me) of a file uploaded
      >> to a php script on the server.[/color]
      >
      > That information usually isn't sent. And see RFC2183 sec.
      > 2.3 (http://www.ietf.org/rfc/rfc2183.txt ).
      >[color=green]
      >> I think $_FILES will only provide 'name', which is only the filename
      >> itself.[/color]
      >
      > But $_FILES['foo']['name'] will be empty if no filename is
      > given to the server. Although they 'should attempt to
      > supply a file name for each submitted file' (HTML4.01 sec.
      > 17.3.4), user agents are not required to supply them.
      >
      > HAGW!
      >[/color]

      I wonder if javascript could get it from the fileupload box, attach it to
      a hidden form, which is available on the next page as a post. Never tried
      it tho.

      Comment

      • Don

        #4
        Re: Retrieving full path of file on upload to php script

        On Sat, 23 Oct 2004 17:29:44 -0000, Theo <invalid@noemai l.com> wrote:
        [color=blue]
        >John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in
        >news:MPG.1be43 caf7f342d419897 90@News.Individ ual.NET:
        >[color=green]
        >> Don wrote:
        >>[color=darkred]
        >>> How do I retrieve the full path (C:\.....filena me) of a file uploaded
        >>> to a php script on the server.[/color]
        >>
        >> That information usually isn't sent. And see RFC2183 sec.
        >> 2.3 (http://www.ietf.org/rfc/rfc2183.txt ).
        >>[color=darkred]
        >>> I think $_FILES will only provide 'name', which is only the filename
        >>> itself.[/color]
        >>
        >> But $_FILES['foo']['name'] will be empty if no filename is
        >> given to the server. Although they 'should attempt to
        >> supply a file name for each submitted file' (HTML4.01 sec.
        >> 17.3.4), user agents are not required to supply them.
        >>
        >> HAGW!
        >>[/color]
        >
        >I wonder if javascript could get it from the fileupload box, attach it to
        >a hidden form, which is available on the next page as a post. Never tried
        >it tho.[/color]
        I'm not sure how to construct the javascript to do what you recommend. Can you show me an example?
        Thanks, Don


        ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
        http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
        ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

        Comment

        • Theo

          #5
          Re: Retrieving full path of file on upload to php script

          Don <no@adr.com> wrote in
          news:q6pln09fia s9bcibl69g4ji51 tbr39u1da@4ax.c om:
          [color=blue]
          > On Sat, 23 Oct 2004 17:29:44 -0000, Theo <invalid@noemai l.com> wrote:
          >[color=green]
          >>John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in
          >>news:MPG.1be4 3caf7f342d41989 790@News.Indivi dual.NET:
          >>[color=darkred]
          >>> Don wrote:
          >>>
          >>>> How do I retrieve the full path (C:\.....filena me) of a file
          >>>> uploaded to a php script on the server.
          >>>
          >>> That information usually isn't sent. And see RFC2183 sec.
          >>> 2.3 (http://www.ietf.org/rfc/rfc2183.txt ).
          >>>
          >>>> I think $_FILES will only provide 'name', which is only the
          >>>> filename itself.
          >>>
          >>> But $_FILES['foo']['name'] will be empty if no filename is
          >>> given to the server. Although they 'should attempt to
          >>> supply a file name for each submitted file' (HTML4.01 sec.
          >>> 17.3.4), user agents are not required to supply them.
          >>>
          >>> HAGW!
          >>>[/color]
          >>
          >>I wonder if javascript could get it from the fileupload box, attach it
          >>to a hidden form, which is available on the next page as a post. Never
          >>tried it tho.[/color]
          > I'm not sure how to construct the javascript to do what you recommend.
          > Can you show me an example? Thanks, Don
          >
          >
          > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
          > News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the
          > World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total
          > Privacy via Encryption =---
          >[/color]

          try this...

          assuming you have the standard fileupload box in a form, call it myimage,
          and the form is myform, add an onfocus function call to the upload box to
          call a function named as you choose.

          In the box put
          onFocus="passfi lename();"

          In the function put:
          filename = document.myform .myimage.value;

          'filename' will be whatever is in the box. then attach that value to the
          hidden field with

          document.myform .hiddenfield.va lue = filename;

          and submit the form.

          use POST to get the value as you would any other. dont know whether it
          will balk at the slashes and colon.

          Comment

          • Don

            #6
            Re: Retrieving full path of file on upload to php script

            On Sun, 24 Oct 2004 00:33:53 -0000, Theo <invalid@noemai l.com> wrote:
            [color=blue]
            >Don <no@adr.com> wrote in
            >news:q6pln09fi as9bcibl69g4ji5 1tbr39u1da@4ax. com:
            >[color=green]
            >> On Sat, 23 Oct 2004 17:29:44 -0000, Theo <invalid@noemai l.com> wrote:
            >>[color=darkred]
            >>>John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in
            >>>news:MPG.1be 43caf7f342d4198 9790@News.Indiv idual.NET:
            >>>
            >>>> Don wrote:
            >>>>
            >>>>> How do I retrieve the full path (C:\.....filena me) of a file
            >>>>> uploaded to a php script on the server.
            >>>>
            >>>> That information usually isn't sent. And see RFC2183 sec.
            >>>> 2.3 (http://www.ietf.org/rfc/rfc2183.txt ).
            >>>>
            >>>>> I think $_FILES will only provide 'name', which is only the
            >>>>> filename itself.
            >>>>
            >>>> But $_FILES['foo']['name'] will be empty if no filename is
            >>>> given to the server. Although they 'should attempt to
            >>>> supply a file name for each submitted file' (HTML4.01 sec.
            >>>> 17.3.4), user agents are not required to supply them.
            >>>>
            >>>> HAGW!
            >>>>
            >>>
            >>>I wonder if javascript could get it from the fileupload box, attach it
            >>>to a hidden form, which is available on the next page as a post. Never
            >>>tried it tho.[/color]
            >> I'm not sure how to construct the javascript to do what you recommend.
            >> Can you show me an example? Thanks, Don
            >>
            >>
            >> ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
            >> News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the
            >> World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total
            >> Privacy via Encryption =---
            >>[/color]
            >
            >try this...
            >
            >assuming you have the standard fileupload box in a form, call it myimage,
            >and the form is myform, add an onfocus function call to the upload box to
            >call a function named as you choose.
            >
            >In the box put
            >onFocus="passf ilename();"
            >
            >In the function put:
            >filename = document.myform .myimage.value;
            >
            >'filename' will be whatever is in the box. then attach that value to the
            >hidden field with
            >
            >document.myfor m.hiddenfield.v alue = filename;
            >
            >and submit the form.
            >
            >use POST to get the value as you would any other. dont know whether it
            >will balk at the slashes and colon.[/color]


            Theo,

            IT WORKS!! I did exactly as you recommended, and it works just great. You don't know how relieved
            I am that this is working. Thank you so much. I don't know what I'd do without these news groups.
            What a tremendous asset. When I'm good enough, I expect to do my share of helping others.

            Thanks again,
            Don


            ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
            http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
            ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

            Comment

            • Jeff North

              #7
              Re: Retrieving full path of file on upload to php script

              On Sat, 23 Oct 2004 19:45:44 -0700, in comp.lang.php Don <no@adr.com>
              wrote:
              [color=blue]
              >| On Sun, 24 Oct 2004 00:33:53 -0000, Theo <invalid@noemai l.com> wrote:[/color]

              [snip]
              [color=blue]
              >| >try this...
              >| >
              >| >assuming you have the standard fileupload box in a form, call it myimage,
              >| >and the form is myform, add an onfocus function call to the upload box to
              >| >call a function named as you choose.
              >| >
              >| >In the box put
              >| >onFocus="passf ilename();"
              >| >
              >| >In the function put:
              >| >filename = document.myform .myimage.value;
              >| >
              >| >'filename' will be whatever is in the box. then attach that value to the
              >| >hidden field with
              >| >
              >| >document.myfor m.hiddenfield.v alue = filename;
              >| >
              >| >and submit the form.
              >| >
              >| >use POST to get the value as you would any other. dont know whether it
              >| >will balk at the slashes and colon.
              >|
              >|
              >| Theo,
              >|
              >| IT WORKS!! I did exactly as you recommended, and it works just great. You don't know how relieved
              >| I am that this is working. Thank you so much. I don't know what I'd do without these news groups.
              >| What a tremendous asset. When I'm good enough, I expect to do my share of helping others.[/color]

              Don, just out of curiosity, why do you want the information on where
              the users is uploading the file from?
              ---------------------------------------------------------------
              jnorth@yourpant sbigpond.net.au : Remove your pants to reply
              ---------------------------------------------------------------

              Comment

              • Don

                #8
                Re: Retrieving full path of file on upload to php script

                On Sun, 24 Oct 2004 08:46:02 GMT, Jeff North <jnorth@yourpan tsbigpond.net.a u> wrote:
                [color=blue]
                >On Sat, 23 Oct 2004 19:45:44 -0700, in comp.lang.php Don <no@adr.com>
                >wrote:
                >[color=green]
                >>| On Sun, 24 Oct 2004 00:33:53 -0000, Theo <invalid@noemai l.com> wrote:[/color]
                >
                >[snip]
                >[color=green]
                >>| >try this...
                >>| >
                >>| >assuming you have the standard fileupload box in a form, call it myimage,
                >>| >and the form is myform, add an onfocus function call to the upload box to
                >>| >call a function named as you choose.
                >>| >
                >>| >In the box put
                >>| >onFocus="passf ilename();"
                >>| >
                >>| >In the function put:
                >>| >filename = document.myform .myimage.value;
                >>| >
                >>| >'filename' will be whatever is in the box. then attach that value to the
                >>| >hidden field with
                >>| >
                >>| >document.myfor m.hiddenfield.v alue = filename;
                >>| >
                >>| >and submit the form.
                >>| >
                >>| >use POST to get the value as you would any other. dont know whether it
                >>| >will balk at the slashes and colon.
                >>|
                >>|
                >>| Theo,
                >>|
                >>| IT WORKS!! I did exactly as you recommended, and it works just great. You don't know how relieved
                >>| I am that this is working. Thank you so much. I don't know what I'd do without these news groups.
                >>| What a tremendous asset. When I'm good enough, I expect to do my share of helping others.[/color]
                >
                >Don, just out of curiosity, why do you want the information on where
                >the users is uploading the file from?
                >---------------------------------------------------------------
                >jnorth@yourpan tsbigpond.net.a u : Remove your pants to reply
                >---------------------------------------------------------------[/color]

                Jeff,

                It's complicated. I'm providing an improved version of a chat group page which has very limited
                capability for attaching pictures. I'm reading in the original page, modifying it to include adding
                browse boxes for uploading pictures. The user clicks on a "Preview" button, afterwhich a
                server-side php script uploads the files, then provides back to the client page a preview of the
                results of his pending post. That preview includes the same form data that he entered on the
                original page, including the file browse boxes. This allows him the opportunity to make any
                changes, afterwhich he clicks on "Previw" again, or "Post", which sends the info to the original
                chat group for posting.. Everything seems to work okay, but now just discovered even though I have
                the full path to his original file, I can't populate the original browse box for a <input
                type=file...>. DARN! Guess the browser is designed that way for security reasons. So, guess I'll
                have to come up with another approach. This has been a real learning curve for me, but I'm having
                fun. Things are coming together pretty well. Just wish I could come up with an answer on this one.
                If you have any ideas I'd appreciate your feedback.

                Thanks for your inquiry.
                Regards, Don


                ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
                http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
                ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

                Comment

                • Jeff North

                  #9
                  Re: Retrieving full path of file on upload to php script

                  On Sun, 24 Oct 2004 05:00:00 -0700, in comp.lang.php Don <no@adr.com>
                  wrote:
                  [color=blue]
                  >| On Sun, 24 Oct 2004 08:46:02 GMT, Jeff North <jnorth@yourpan tsbigpond.net.a u> wrote:
                  >|
                  >| >On Sat, 23 Oct 2004 19:45:44 -0700, in comp.lang.php Don <no@adr.com>
                  >| >wrote:[/color]

                  [snip]
                  [color=blue]
                  >| >Don, just out of curiosity, why do you want the information on where
                  >| >the users is uploading the file from?
                  >| >---------------------------------------------------------------
                  >| >jnorth@yourpan tsbigpond.net.a u : Remove your pants to reply
                  >| >---------------------------------------------------------------
                  >|
                  >| Jeff,
                  >|
                  >| It's complicated. I'm providing an improved version of a chat group page which has very limited
                  >| capability for attaching pictures. I'm reading in the original page, modifying it to include adding
                  >| browse boxes for uploading pictures. The user clicks on a "Preview" button, afterwhich a
                  >| server-side php script uploads the files, then provides back to the client page a preview of the
                  >| results of his pending post. That preview includes the same form data that he entered on the
                  >| original page, including the file browse boxes. This allows him the opportunity to make any
                  >| changes, afterwhich he clicks on "Previw" again, or "Post", which sends the info to the original
                  >| chat group for posting.. Everything seems to work okay, but now just discovered even though I have
                  >| the full path to his original file, I can't populate the original browse box for a <input
                  >| type=file...>. DARN! Guess the browser is designed that way for security reasons. So, guess I'll
                  >| have to come up with another approach. This has been a real learning curve for me, but I'm having
                  >| fun. Things are coming together pretty well. Just wish I could come up with an answer on this one.
                  >| If you have any ideas I'd appreciate your feedback.
                  >|
                  >| Thanks for your inquiry.[/color]

                  I don't know if this is going to help or hinder your progress.
                  If you look at the discussion forum on
                  http://www.interactivetools.com/foru....cgi?forum=18; then do a
                  search on image, image preview etc. The basic app (htmlArea) simply
                  has a dialog box where you type in the url of the image. Other people
                  have wanted image preview (amongst other things). It might give you an
                  idea of what is involved. You might even find some code there that you
                  can use.

                  Also, if you still have the full path and filename in the input box
                  you might want to prepend file:/// to the name.
                  ---------------------------------------------------------------
                  jnorth@yourpant sbigpond.net.au : Remove your pants to reply
                  ---------------------------------------------------------------

                  Comment

                  • Don

                    #10
                    Re: Retrieving full path of file on upload to php script

                    On Sun, 24 Oct 2004 15:34:27 GMT, Jeff North <jnorth@yourpan tsbigpond.net.a u> wrote:
                    [color=blue]
                    >On Sun, 24 Oct 2004 05:00:00 -0700, in comp.lang.php Don <no@adr.com>
                    >wrote:
                    >[color=green]
                    >>| On Sun, 24 Oct 2004 08:46:02 GMT, Jeff North <jnorth@yourpan tsbigpond.net.a u> wrote:
                    >>|
                    >>| >On Sat, 23 Oct 2004 19:45:44 -0700, in comp.lang.php Don <no@adr.com>
                    >>| >wrote:[/color]
                    >
                    >[snip]
                    >[color=green]
                    >>| >Don, just out of curiosity, why do you want the information on where
                    >>| >the users is uploading the file from?
                    >>| >---------------------------------------------------------------
                    >>| >jnorth@yourpan tsbigpond.net.a u : Remove your pants to reply
                    >>| >---------------------------------------------------------------
                    >>|
                    >>| Jeff,
                    >>|
                    >>| It's complicated. I'm providing an improved version of a chat group page which has very limited
                    >>| capability for attaching pictures. I'm reading in the original page, modifying it to include adding
                    >>| browse boxes for uploading pictures. The user clicks on a "Preview" button, afterwhich a
                    >>| server-side php script uploads the files, then provides back to the client page a preview of the
                    >>| results of his pending post. That preview includes the same form data that he entered on the
                    >>| original page, including the file browse boxes. This allows him the opportunity to make any
                    >>| changes, afterwhich he clicks on "Previw" again, or "Post", which sends the info to the original
                    >>| chat group for posting.. Everything seems to work okay, but now just discovered even though I have
                    >>| the full path to his original file, I can't populate the original browse box for a <input
                    >>| type=file...>. DARN! Guess the browser is designed that way for security reasons. So, guess I'll
                    >>| have to come up with another approach. This has been a real learning curve for me, but I'm having
                    >>| fun. Things are coming together pretty well. Just wish I could come up with an answer on this one.
                    >>| If you have any ideas I'd appreciate your feedback.
                    >>|
                    >>| Thanks for your inquiry.[/color]
                    >
                    >I don't know if this is going to help or hinder your progress.
                    >If you look at the discussion forum on
                    >http://www.interactivetools.com/foru....cgi?forum=18; then do a
                    >search on image, image preview etc. The basic app (htmlArea) simply
                    >has a dialog box where you type in the url of the image. Other people
                    >have wanted image preview (amongst other things). It might give you an
                    >idea of what is involved. You might even find some code there that you
                    >can use.
                    >
                    >Also, if you still have the full path and filename in the input box
                    >you might want to prepend file:/// to the name.
                    >---------------------------------------------------------------
                    >jnorth@yourpan tsbigpond.net.a u : Remove your pants to reply
                    >---------------------------------------------------------------[/color]

                    Thanks Jeff. I checked out that forum. It looks like it should be of great help.
                    Regards,
                    Don


                    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
                    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
                    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

                    Comment

                    Working...