[thelist] Free Tip for PHP

Rob Smith rob.smith at THERMON.com
Mon Jul 21 09:17:59 CDT 2003


Hi,

<tip type="Getting File Names from <input type="file"> fields with PHP"
author="Rob.Smith">
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.
</tip>

Rob.Smith



More information about the thelist mailing list