473,230 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

Path Function?

I'm reading the php manual to find out how to get the path of a file
I'm uploading from my PC - I'm using the $_FILES[FileToUpload][name]
var but that is just the filename - is there a function that I can use
to get it's full path too? or is it by the time php gets it it's on
the server so it's too late to worry about it? do I have to get into
javascript to get the path on the PC side??? I'm trying to check the
filesize before having to upload the file to the server only to find
out it's too big for the limit I'm setting...

Thanks...

Jul 16 '05 #1
1 4208
Ralph Freshour wrote:
I'm reading the php manual to find out how to get the path of a file
I'm uploading from my PC - I'm using the $_FILES[FileToUpload][name]
var but that is just the filename - is there a function that I can use
to get it's full path too? or is it by the time php gets it it's on
the server so it's too late to worry about it? do I have to get into
javascript to get the path on the PC side??? I'm trying to check the
filesize before having to upload the file to the server only to find
out it's too big for the limit I'm setting...
As far as I'm aware, the path to the file on the client machine is not
available in PHP - like you say, there's no point in knowing it (and it
could constitute a security issue, knowing things about the client's
file structure).

However, if you really must have it (but don't mind it not being
available if the client doesn't have Javascript turned on), you could
have a hidden text field in your form which gets populated with the
contents of the file upload field when the form is submitted.

I think the reasons you are wanting to do this are fruitless however.
You say you want to check the size of the file before it is uploaded.
This can't be done. The only way the server can know how big it is is by
uploading it fully. Javascript cannot get access to the filesize on the
client machine for security reasons (it cannot access the client's
filesystem).

That said, you can set MAX_FILE_SIZE, which cause PHP to report straight
away if the size of the file to be uploaded is too big, in which case
the file won't be uploaded at all (the browser doesn't bother). This
isn't the case in all browsers, but I think IE6 plays fair so you'll be
catching the majority of users. You will, of course, still have to code
for those browsers which will still upload the file.

Hope this helps.

MK.
Thanks...


--
MeerKat

Jul 16 '05 #2

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

Similar topics

70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
5
by: Jean Paul Sartre | last post by:
can anyone suggest a function that will spit out the dom path for an object on id? I'm having troubles targettting elements so i thought, if i make a function that spits path (you send it id) then...
2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
4
by: tommaso.gastaldi | last post by:
Hi friends I was in the need to find a sort of "definitive" :) solution to transform a virtual path such as "~/MyDir/MyFile into a full web address. In particular I needed it * within web...
7
by: ApexData | last post by:
Hello I currently Link the FE/BE using the LinkTables Option and the Linked Table Manager. Any time I need to move the BE to another location, I have to go through this process over again. I...
5
by: 7stud | last post by:
Here's the code: ------------ import os, os.path, pprint mydir = "/Users/me/2testing" files = pprint.pprint(files) print os.path.join(mydir, "helloWorld.py")
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
13
by: lawpoop | last post by:
Hello all - I have a two part question. First of all, I have a website under /home/user/www/. The index.php and all the other website pages are under /home/user/www/. For functions that are...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.