473,395 Members | 1,537 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,395 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 4214
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.