Professional Web Applications Themes

Retrieving full path of file on upload to php script - PHP Development

How do I retrieve the full path (C:\.....filename) 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==---- [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =---...

  1. #1

    Default Retrieving full path of file on upload to php script

    How do I retrieve the full path (C:\.....filename) 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==----
    [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
    Don Guest

  2. #2

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

    $path=$_SERVER["DOENT_ROOT"];

    "Don" <noadr.com> schreef in bericht
    news:tr8kn0huoh1lk1uq54aqefjr6ll005vgt14ax.com...
    > How do I retrieve the full path (C:\.....filename) 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==----
    > [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! >100,000
    > Newsgroups
    > ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

    Polaris Guest

  3. #3

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

    On Sat, 23 Oct 2004 12:27:19 +0200, "Polaris" <ask4polarishotmail.com> wrote:
    >$path=$_SERVER["DOENT_ROOT"];
    >
    >"Don" <noadr.com> schreef in bericht
    >news:tr8kn0huoh1lk1uq54aqefjr6ll005vgt14ax.com.. .
    >> How do I retrieve the full path (C:\.....filename) 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==----
    >> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! >100,000
    >> Newsgroups
    >> ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
    Thanks for your reply.

    Following in client-side <form>
    ------------------------------------
    <p>Picture #1:<br><input type=file name="userfile[]" size=90 maxlength=200000 accept="image/jpeg"
    tabindex=1>\n';

    <p>Picture #2:<br><input type=file name="userfile[]" size=90 maxlength=200000 accept="image/jpeg"
    tabindex=3>\n';


    Tried the following in server-side php script, but it provided the path on the server where the file
    was uploaded. What I need is the full path where the file resided on the client machine. I need it
    for each of the two uploads. Any ideas?
    --------------------------------------------------------------------------------------------------------------------
    print("Doent root: = ".$_SERVER['doent_root']."\n");



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

  4. #4

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

    Try this one. Does it solve your problem?

    Save as index.php

    <?php

    if (isset($_POST["file1"])) $file1=$_POST["file1"];
    if (isset($_POST["file2"])) $file2=$_POST["file2"];

    print "File 1 = " . $file1;
    print "<br />File 2 = " . $file2;


    print '<form id="UploadForm" action="index.php" method="post">
    <div>
    <h1>Select your files</h1>
    <strong>1</strong>. <input type="file" name="file1" size="70"
    style="margin-bottom: 3px"/>
    <br />
    <strong>2</strong>. <input type="file" name="file2" size="70"
    style="margin-bottom: 3px"/>
    <br />
    <input type=submit name=up value="Upload">
    </div>
    </form>';

    ?>

    "Don" <noadr.com> schreef in bericht
    news:17skn01fs2udikt14ac7i822vute9mrkc64ax.com...
    > On Sat, 23 Oct 2004 12:27:19 +0200, "Polaris" <ask4polarishotmail.com>
    > wrote:
    >
    >>$path=$_SERVER["DOENT_ROOT"];
    >>
    >>"Don" <noadr.com> schreef in bericht
    >>news:tr8kn0huoh1lk1uq54aqefjr6ll005vgt14ax.com. ..
    >>> How do I retrieve the full path (C:\.....filename) 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==----
    >>> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! >100,000
    >>> Newsgroups
    >>> ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
    >
    > Thanks for your reply.
    >
    > Following in client-side <form>
    > ------------------------------------
    > <p>Picture #1:<br><input type=file name="userfile[]" size=90
    > maxlength=200000 accept="image/jpeg"
    > tabindex=1>\n';
    >
    > <p>Picture #2:<br><input type=file name="userfile[]" size=90
    > maxlength=200000 accept="image/jpeg"
    > tabindex=3>\n';
    >
    >
    > Tried the following in server-side php script, but it provided the path on
    > the server where the file
    > was uploaded. What I need is the full path where the file resided on the
    > client machine. I need it
    > for each of the two uploads. Any ideas?
    > --------------------------------------------------------------------------------------------------------------------
    > print("Doent root: = ".$_SERVER['doent_root']."\n");
    >
    >
    >
    > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
    > News==----
    > [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! >100,000
    > Newsgroups
    > ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

    Polaris Guest

  5. #5

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

    Tried it, but $file1 and $file2 are returned empty. I think maybe I need to be using
    $GLOBALS['HTTP_RAW_POST_DATA'] or php://input. But, I can't seem to get them to work either. Any
    ideas?

    Thanks, Don


    On Sat, 23 Oct 2004 21:01:19 +0200, "Polaris" <ask4polarishotmail.com> wrote:
    >Try this one. Does it solve your problem?
    >
    >Save as index.php
    >
    ><?php
    >
    >if (isset($_POST["file1"])) $file1=$_POST["file1"];
    >if (isset($_POST["file2"])) $file2=$_POST["file2"];
    >
    >print "File 1 = " . $file1;
    >print "<br />File 2 = " . $file2;
    >
    >
    >print '<form id="UploadForm" action="index.php" method="post">
    > <div>
    > <h1>Select your files</h1>
    > <strong>1</strong>. <input type="file" name="file1" size="70"
    >style="margin-bottom: 3px"/>
    > <br />
    > <strong>2</strong>. <input type="file" name="file2" size="70"
    >style="margin-bottom: 3px"/>
    > <br />
    > <input type=submit name=up value="Upload">
    > </div>
    ></form>';
    >
    >?>
    >
    >"Don" <noadr.com> schreef in bericht
    >news:17skn01fs2udikt14ac7i822vute9mrkc64ax.com.. .
    >> On Sat, 23 Oct 2004 12:27:19 +0200, "Polaris" <ask4polarishotmail.com>
    >> wrote:
    >>
    >>>$path=$_SERVER["DOENT_ROOT"];
    >>>
    >>>"Don" <noadr.com> schreef in bericht
    >>>news:tr8kn0huoh1lk1uq54aqefjr6ll005vgt14ax.com ...
    >>>> How do I retrieve the full path (C:\.....filename) 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==----
    >>>> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! >100,000
    >>>> Newsgroups
    >>>> ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
    >>
    >> Thanks for your reply.
    >>
    >> Following in client-side <form>
    >> ------------------------------------
    >> <p>Picture #1:<br><input type=file name="userfile[]" size=90
    >> maxlength=200000 accept="image/jpeg"
    >> tabindex=1>\n';
    >>
    >> <p>Picture #2:<br><input type=file name="userfile[]" size=90
    >> maxlength=200000 accept="image/jpeg"
    >> tabindex=3>\n';
    >>
    >>
    >> Tried the following in server-side php script, but it provided the path on
    >> the server where the file
    >> was uploaded. What I need is the full path where the file resided on the
    >> client machine. I need it
    >> for each of the two uploads. Any ideas?
    >> --------------------------------------------------------------------------------------------------------------------
    >> print("Doent root: = ".$_SERVER['doent_root']."\n");
    >>
    >>
    >>
    >> ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
    >> News==----
    >> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! >100,000
    >> Newsgroups
    >> ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
    >


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

  6. #6

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


    "Don" <noadr.com> schreef in bericht
    news:bvoln05dbb573qkjsrhf91l7n0d9rvbfot4ax.com...
    > Tried it, but $file1 and $file2 are returned empty. I think maybe I need
    > to be using
    > $GLOBALS['HTTP_RAW_POST_DATA'] or php://input. But, I can't seem to get
    > them to work either. Any
    > ideas?
    >
    > Thanks, Don
    >
    >
    > On Sat, 23 Oct 2004 21:01:19 +0200, "Polaris" <ask4polarishotmail.com>
    > wrote:
    >
    >>Try this one. Does it solve your problem?
    >>
    >>Save as index.php
    >>
    >><?php
    >>
    >>if (isset($_POST["file1"])) $file1=$_POST["file1"];
    >>if (isset($_POST["file2"])) $file2=$_POST["file2"];
    >>
    >>print "File 1 = " . $file1;
    >>print "<br />File 2 = " . $file2;
    >>
    >>
    >>print '<form id="UploadForm" action="index.php" method="post">
    >> <div>
    >> <h1>Select your files</h1>
    >> <strong>1</strong>. <input type="file" name="file1" size="70"
    >>style="margin-bottom: 3px"/>
    >> <br />
    >> <strong>2</strong>. <input type="file" name="file2" size="70"
    >>style="margin-bottom: 3px"/>
    >> <br />
    >> <input type=submit name=up value="Upload">
    >> </div>
    >></form>';
    >>
    >>?>
    Strange when I run the script here at my local apache server and I fill in
    the form $file1 and $file2 do have returning values... I gives complete path
    with filename something like K:\\www\\filename.ext Or maybe I don't
    understand your problem clearly???


    Polaris Guest

  7. #7

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

    Read up on the $_FILES scope and handling file uploads here >>
    ([url]http://us2.php.net/features.file-upload[/url])

    This provides alot more information than you think
    You can get the client filename, the temp file, as well as size and any
    upload errors.

    Using the basename() function, you can also trim down the filename to get
    the name and extension as well.

    V/r,
    Charles

    "Polaris" <ask4polarishotmail.com> wrote in message
    news:417b74a1$0$44103$5fc3050dreader2.news.tiscal i.nl...
    >
    > "Don" <noadr.com> schreef in bericht
    > news:bvoln05dbb573qkjsrhf91l7n0d9rvbfot4ax.com...
    > > Tried it, but $file1 and $file2 are returned empty. I think maybe I
    need
    > > to be using
    > > $GLOBALS['HTTP_RAW_POST_DATA'] or php://input. But, I can't seem to get
    > > them to work either. Any
    > > ideas?
    > >
    > > Thanks, Don
    > >
    > >
    > > On Sat, 23 Oct 2004 21:01:19 +0200, "Polaris" <ask4polarishotmail.com>
    > > wrote:
    > >
    > >>Try this one. Does it solve your problem?
    > >>
    > >>Save as index.php
    > >>
    > >><?php
    > >>
    > >>if (isset($_POST["file1"])) $file1=$_POST["file1"];
    > >>if (isset($_POST["file2"])) $file2=$_POST["file2"];
    > >>
    > >>print "File 1 = " . $file1;
    > >>print "<br />File 2 = " . $file2;
    > >>
    > >>
    > >>print '<form id="UploadForm" action="index.php" method="post">
    > >> <div>
    > >> <h1>Select your files</h1>
    > >> <strong>1</strong>. <input type="file" name="file1" size="70"
    > >>style="margin-bottom: 3px"/>
    > >> <br />
    > >> <strong>2</strong>. <input type="file" name="file2" size="70"
    > >>style="margin-bottom: 3px"/>
    > >> <br />
    > >> <input type=submit name=up value="Upload">
    > >> </div>
    > >></form>';
    > >>
    > >>?>
    >
    > Strange when I run the script here at my local apache server and I fill in
    > the form $file1 and $file2 do have returning values... I gives complete
    path
    > with filename something like K:\\www\\filename.ext Or maybe I don't
    > understand your problem clearly???
    >
    >

    Charles Pelkey Guest

  8. #8

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

    Quote Originally Posted by Polaris View Post
    Try this one. Does it solve your problem?

    Save as index.php

    <?php

    if (isset($_POST["file1"])) $file1=$_POST["file1"];
    if (isset($_POST["file2"])) $file2=$_POST["file2"];

    print "File 1 = " . $file1;
    print "<br />File 2 = " . $file2;


    print '<form id="UploadForm" action="index.php" method="post">
    <div>
    <h1>Select your files</h1>
    <strong>1</strong>. <input type="file" name="file1" size="70"
    style="margin-bottom: 3px"/>
    <br />
    <strong>2</strong>. <input type="file" name="file2" size="70"
    style="margin-bottom: 3px"/>
    <br />
    <input type=submit name=up value="Upload">
    </div>
    </form>';

    ?>

    "Don" <noadr.com> schreef in bericht
    news:17skn01fs2udikt14ac7i822vute9mrkc64ax.com...
    Thanks For u r help..........I m new to PHP
    then Its only working in IE Browser only ...
    what about other browser............

    Waiting for your Response.................
    Prakash R is offline Junior Member
    Join Date
    Apr 2013
    Location
    Chennai,Shoinganallur
    Posts
    2

  9. #9

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

    Thanks For u r help..........I m new to PHP
    then Its only working in IE Browser only ...
    what about other browser............

    Waiting for your Response.................
    Prakash R is offline Junior Member
    Join Date
    Apr 2013
    Location
    Chennai,Shoinganallur
    Posts
    2

Similar Threads

  1. How to get the full path of the current open PDF file?
    By yiyun0918@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 2
    Last Post: March 27th, 03:44 AM
  2. Insert full path on browse file?
    By J?J in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: March 26th, 07:05 AM
  3. cffile upload file field returns temporary path
    By Rustywater in forum Macromedia ColdFusion
    Replies: 2
    Last Post: February 25th, 08:27 PM
  4. File upload script
    By boris bass in forum PERL Beginners
    Replies: 9
    Last Post: November 19th, 02:10 AM
  5. grabbing full path and file name
    By George in forum Microsoft Access
    Replies: 0
    Last Post: July 30th, 08:06 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139