[thelist] Free Tip for PHP
Jay Blanchard
jay.blanchard at niicommunications.com
Mon Jul 21 09:32:11 CDT 2003
[snip]
I made neat script that will/should help with file uploading and the
<input
type="file"> button. I wanted the file name so I did this:
(complete file path is set via method="GET" in my form and the file
fields
name is "Info")
$Info = $_GET["Info"];
$Info = split("\\\\",$Info);
echo $Info[count($Info)-1]; // get the file name
and the output was in fact:
file.htm
original path:
C:\Documents and Settings\...\My Documents\file.htm
The nice thing about this is that it will grab the file name regardless
of
how long the file path is.
[/snip]
An easier way to get the filename;
PHP earlier than 4.1 -- $HTTP_POST_FILES['userfile']['name']
PHP after that -- $_FILES['userfile']['name']
See http://us2.php.net/manual/en/features.file-upload.php
There is a lot of information that you can get about uploaded files that
are contained in these variable arrays.
HTH!
More information about the thelist
mailing list