我正在使用以下php文件,
结果
Upload: test.com.html
Type: text/html
Size: 135.921875 kB
Stored in: /tmp/phpA8DGdB
Possible file upload attack!
Here is some more debugging info:
Array (
[file] =>
Array (
[name] => test.com.html
[type] => text/html
[tmp_name] => /tmp/phpA8DGdB
[error] => 0
[size] => 139184
)
)
PHP文件: -
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
$uploaddir = '/var/www/setup/upload';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
所以,我无法上传文件。我将不胜感激,提前致谢: - )
答案 0 :(得分:2)
您需要$uploaddir
和文件名之间的目录分隔符:
$uploaddir = '/var/www/setup/upload/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);