mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
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:
parent
5d5df1741d
commit
3305b5e987
1 changed files with 4 additions and 13 deletions
|
@ -80,20 +80,11 @@ Send this file: <INPUT NAME="userfile" TYPE="file">
|
|||
<title>Validating file uploads.</title>
|
||||
<programlisting>
|
||||
<?
|
||||
$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;
|
||||
|
|
Loading…
Reference in a new issue