Retrieving full path of file on upload to php script

This is a discussion on Retrieving full path of file on upload to php script within the alt.comp.lang.php forums, part of the PHP Programming Forums category; How do I retrieve the full path (C:\.....filename) of a file uploaded to a php script on the server. ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-23-2004
Don
 
Posts: n/a
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==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Reply With Quote
  #2 (permalink)  
Old 10-23-2004
Polaris
 
Posts: n/a
Default Re: Retrieving full path of file on upload to php script

$path=$_SERVER["DOCUMENT_ROOT"];

"Don" <no@adr.com> schreef in bericht
news:tr8kn0huoh1lk1uq54aqefjr6ll005vgt1@4ax.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==----
> http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
> Newsgroups
> ---= East/West-Coast Server Farms - Total Privacy via Encryption =---



Reply With Quote
  #3 (permalink)  
Old 10-23-2004
Don
 
Posts: n/a
Default Re: Retrieving full path of file on upload to php script

On Sat, 23 Oct 2004 12:27:19 +0200, "Polaris" <ask4polaris@hotmail.com> wrote:

>$path=$_SERVER["DOCUMENT_ROOT"];
>
>"Don" <no@adr.com> schreef in bericht
>news:tr8kn0huoh1lk1uq54aqefjr6ll005vgt1@4ax.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==----
>> http://www.newsfeeds.com 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("Document root: = ".$_SERVER['document_root']."\n");



----== 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 =---
Reply With Quote
  #4 (permalink)  
Old 10-23-2004
Polaris
 
Posts: n/a
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" <no@adr.com> schreef in bericht
news:17skn01fs2udikt14ac7i822vute9mrkc6@4ax.com...
> On Sat, 23 Oct 2004 12:27:19 +0200, "Polaris" <ask4polaris@hotmail.com>
> wrote:
>
>>$path=$_SERVER["DOCUMENT_ROOT"];
>>
>>"Don" <no@adr.com> schreef in bericht
>>news:tr8kn0huoh1lk1uq54aqefjr6ll005vgt1@4ax.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==----
>>> http://www.newsfeeds.com 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("Document root: = ".$_SERVER['document_root']."\n");
>
>
>
> ----== 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 =---



Reply With Quote
  #5 (permalink)  
Old 10-24-2004
Don
 
Posts: n/a
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" <ask4polaris@hotmail.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" <no@adr.com> schreef in bericht
>news:17skn01fs2udikt14ac7i822vute9mrkc6@4ax.com.. .
>> On Sat, 23 Oct 2004 12:27:19 +0200, "Polaris" <ask4polaris@hotmail.com>
>> wrote:
>>
>>>$path=$_SERVER["DOCUMENT_ROOT"];
>>>
>>>"Don" <no@adr.com> schreef in bericht
>>>news:tr8kn0huoh1lk1uq54aqefjr6ll005vgt1@4ax.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==----
>>>> http://www.newsfeeds.com 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("Document root: = ".$_SERVER['document_root']."\n");
>>
>>
>>
>> ----== 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 =---

>




----== 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 =---
Reply With Quote
  #6 (permalink)  
Old 10-24-2004
Polaris
 
Posts: n/a
Default Re: Retrieving full path of file on upload to php script


"Don" <no@adr.com> schreef in bericht
news:bvoln05dbb573qkjsrhf91l7n0d9rvbfot@4ax.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" <ask4polaris@hotmail.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???


Reply With Quote
  #7 (permalink)  
Old 10-24-2004
Charles Pelkey
 
Posts: n/a
Default Re: Retrieving full path of file on upload to php script

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

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" <ask4polaris@hotmail.com> wrote in message
news:417b74a1$0$44103$5fc3050@dreader2.news.tiscal i.nl...
>
> "Don" <no@adr.com> schreef in bericht
> news:bvoln05dbb573qkjsrhf91l7n0d9rvbfot@4ax.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" <ask4polaris@hotmail.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???
>
>



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:08 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0