| Files Uploaded |
| File Name |
File size |
/*
* SET THE SAVE PATH by editing the line below. Make sure that the path
* name ends with the correct file system path separator ('/' in linux and
* '\\' in windows servers (eg "c:\\temp\\uploads\\" )
*/
$save_path="/tmp/junk/";
$userfile_parent = $_REQUEST['userfile_parent'];
$file = $_FILES['userfile'];
$k = count($file['name']);
for($i=0 ; $i < $k ; $i++)
{
if($i %2)
{
echo ' ';
}
else
{
echo '
';
}
if(isset($save_path) && $save_path!="")
{
if(isset($userfile_parent))
{
/*
* Please refer to the encode_path parameter of Rad Upload
* http://www.radinks.com/upload/settings
*/
$name = str_replace($userfile_parent,"",urldecode($file['name'][$i]));
error_log($name);
$path ="$save_path" . dirname($name);
if(preg_match('/(;)|(\.\.)/',$path))
{
echo "| $path | rejected |
";
continue;
}
if(file_exists($path))
{
if(!is_dir($path))
{
/*
* a file by that name already exists and it's not a directory.
* You will need to handle this situation according to your
* requirements. You have a range of options including siliently
* ingoring this file or rejecting the upload as a whole.
*/
error_log("file exists $path");
}
}
else
{
/*
* We need to create a directory. Notice that we are not pretending
* to be thread safe here.
*/
error_log('making path ' . $path);
`mkdir -p $path`;
}
}
else
{
$name = basename($file['name'][$i]);
}
/*
* now we can safely move the file from it's temporary location to a more
* permanent home.
*/
move_uploaded_file($file['tmp_name'][$i], $save_path . $name);
}
echo '' . $file['name'][$i] ." | \n";
echo '' . $file['size'][$i] ." | \n";
}
if(! isset($save_path) || $save_path =="")
{
echo '| Files have not been saved, please edit upload.php to match your configuration |
';
}
echo "| Top level folder hint : $userfile_parent |
";
?>
Sample PHP Upload handler provided by
Rad Inks
have you seen our Secure FTP Applet or
our Multimedia Messaging Solution?