473,545 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4219
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
4037
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 Python standard library, and Reinhold Birkenfeld started a discussion on it in python-dev...
34
3233
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: /python/nondist/sandbox/path/{path.py,test_path.py} One thing is still different, though: a Path instance won't compare to a regular string.
5
2103
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 it would help html has: <div name="nav"> <a href="yo">hey</a><p>this <h1 id="io">hey</h1></p></div> i want to do something like
2
23365
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 using '/' as delimiters and get the last 'word'. The reason I'm not entirely happy with that method is that it is platform specific. I would prefer...
5
8604
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". Same file path containing special characters works fine in one machine, but doesn't work in other. I am using following API function to get short...
4
3220
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 services *. I would like to be informed that the framework provides a function to do that, but for now I am missing it.
7
2939
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 need the flexibility of being able to move the BE data to wherever I want, without manually going through this process. I just want to change the...
5
8115
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
6884
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 function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in...
13
2786
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 used in multiple files, I have php files under / home/user/www/functions/. These files simply have So, in index.php and other files, I have
0
7420
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...
0
7680
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. ...
0
7934
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
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...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3476
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...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.