473,839 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving full path of file on upload to php script

Don
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 =---
Jul 17 '05 #1
9 5410
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!

--
Jock
Jul 17 '05 #2
John Dunlop <us*********@jo hn.dunlop.name> wrote in
news:MP******** *************** *@News.Individu al.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.
Jul 17 '05 #3
Don
On Sat, 23 Oct 2004 17:29:44 -0000, Theo <in*****@noemai l.com> wrote:
John Dunlop <us*********@jo hn.dunlop.name> wrote in
news:MP******* *************** **@News.Individ ual.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.

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 =---
Jul 17 '05 #4
Don <no@adr.com> wrote in
news:q6******** *************** *********@4ax.c om:
On Sat, 23 Oct 2004 17:29:44 -0000, Theo <in*****@noemai l.com> wrote:
John Dunlop <us*********@jo hn.dunlop.name> wrote in
news:MP****** *************** ***@News.Indivi dual.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.

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 =---


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.
Jul 17 '05 #5
Don
On Sun, 24 Oct 2004 00:33:53 -0000, Theo <in*****@noemai l.com> wrote:
Don <no@adr.com> wrote in
news:q6******* *************** **********@4ax. com:
On Sat, 23 Oct 2004 17:29:44 -0000, Theo <in*****@noemai l.com> wrote:
John Dunlop <us*********@jo hn.dunlop.name> wrote in
news:MP***** *************** ****@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.

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 =---


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.

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 =---
Jul 17 '05 #6
On Sat, 23 Oct 2004 19:45:44 -0700, in comp.lang.php Don <no@adr.com>
wrote:
| On Sun, 24 Oct 2004 00:33:53 -0000, Theo <in*****@noemai l.com> wrote:
[snip]
| >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.


Don, just out of curiosity, why do you want the information on where
the users is uploading the file from?
---------------------------------------------------------------
jn****@yourpant sbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 17 '05 #7
Don
On Sun, 24 Oct 2004 08:46:02 GMT, Jeff North <jn****@yourpan tsbigpond.net.a u> wrote:
On Sat, 23 Oct 2004 19:45:44 -0700, in comp.lang.php Don <no@adr.com>
wrote:
| On Sun, 24 Oct 2004 00:33:53 -0000, Theo <in*****@noemai l.com> wrote:


[snip]
| >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.


Don, just out of curiosity, why do you want the information on where
the users is uploading the file from?
---------------------------------------------------------------
jn****@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.
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 =---
Jul 17 '05 #8
On Sun, 24 Oct 2004 05:00:00 -0700, in comp.lang.php Don <no@adr.com>
wrote:
| On Sun, 24 Oct 2004 08:46:02 GMT, Jeff North <jn****@yourpan tsbigpond.net.a u> wrote:
|
| >On Sat, 23 Oct 2004 19:45:44 -0700, in comp.lang.php Don <no@adr.com>
| >wrote:
[snip]
| >Don, just out of curiosity, why do you want the information on where
| >the users is uploading the file from?
| >---------------------------------------------------------------
| >jn****@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.


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.
---------------------------------------------------------------
jn****@yourpant sbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 17 '05 #9
Don
On Sun, 24 Oct 2004 15:34:27 GMT, Jeff North <jn****@yourpan tsbigpond.net.a u> wrote:
On Sun, 24 Oct 2004 05:00:00 -0700, in comp.lang.php Don <no@adr.com>
wrote:
| On Sun, 24 Oct 2004 08:46:02 GMT, Jeff North <jn****@yourpan tsbigpond.net.a u> wrote:
|
| >On Sat, 23 Oct 2004 19:45:44 -0700, in comp.lang.php Don <no@adr.com>
| >wrote:


[snip]
| >Don, just out of curiosity, why do you want the information on where
| >the users is uploading the file from?
| >---------------------------------------------------------------
| >jn****@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.


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.
---------------------------------------------------------------
jn****@yourpan tsbigpond.net.a u : Remove your pants to reply
---------------------------------------------------------------


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 =---
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1812
by: Willoughby Bridge | last post by:
I am having trouble with a file upload script. Have tried a lot of different methods and the problem boils down to the $_FILES variable not being picked up. Below is a simple example of Upload2.php having a blank value for $_FILES. I am using PHP through my web host yahoo. I'd appreciate any thoughts on how to resolve this this. <form enctype="multipart/form-data" method="post" action="upload2.php"> Send this file: <input...
2
7476
by: SU_Oran | last post by:
I found this when searching. I need to have a simple script that will upload a single file. It is giving me an error on Set upl = Server.CreateObject("ASPSimpleUpload.Upload") It is saying : Server object, ASP 0177 (0x800401F3) Invalid class string Am I missing something? A DLL perhaps?
2
2158
by: Chuck | last post by:
Hi, can anyone provide or point me in the direction of a simple python file upload script? I've got the HTML form part going but simply putting the file in a directory on the server is what I'm looking for. Any help would be greatly appreciated. Thanks, Chuck
7
5084
by: gmax2006 | last post by:
Hi, I use RedHat linux. How can I find where exactly the current python script is running? I use this code: #test.py import os,sys
7
3194
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
1
1843
by: fatjoez | last post by:
Hey there. I've been trying to modify my file upload script so that it handles 10 files instead of one. i was thinking the most straightforward way would be to add a FOR LOOP? placed strategically somewhere like just before the my variables get declared??? the POST input name is "fileup" so maybe i could call them fileup1, fileup2 etc. This is the upld.pl script itself.
0
2318
by: wasif | last post by:
I am trying to upload file using ajax and php but having some problems. it always says that there was a problem and file is not uploaded. here is the code form and ajax code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled...
1
3961
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need my objective is this that when i uplod a file it should be desply on same page with ajax uplod after when i refresh page this should be not remains longer and on clicking other image its replase previous image plz help how i can do this the...
24
7754
by: owz2008 | last post by:
This has probably been covered before but could not find a similar thread. Basically I have created a form which can be viewed at www.icomworks.co.uk/canvaspayform.html I want to submit the form along with the file so that they are both placed on my server... I have created a folder on my server in my public_html called myscripts and have saved my upload.cgi script into that folder. my form points to that script but when I fill in the...
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10914
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10656
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.