Simplified with basename.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@31990 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Ron Chmara 2000-09-05 02:17:38 +00:00
parent 5d5df1741d
commit 3305b5e987

View file

@ -80,20 +80,11 @@ Send this file: <INPUT NAME="userfile" TYPE="file">
<title>Validating file uploads.</title>
<programlisting>
&lt?
$validtmpdir = get_cfg_var("upload_tmp_dir");
// get the path
// Make sure file is coming from upload directory
$uploadpath = get_cfg_var('upload_tmp_dir') . '/' . basename($userfile);
$uploaded_path_array = spilt("/","$userfile");
//split the upload name into its components
$inverted_path = array_reverse ($uploaded_path_array);
// reverse the array, so any ending pathname will now be first
$accurate_pathname = "$validtmpdir" . "$inverted_path[0]";
if (file_exists($accurate_pathname )){
//still look for proper temp name
copy ("$accurate_pathname", "/place/to/put/uploaded/file");
if (file_exists($uploadpath)){
copy ("$uploadpath", "/place/to/put/uploaded/file");
} else {
echo "Not an uploaded file!";
exit;