我做了简单的功能:
function get($field, $dir = 'dir/') {
$file_tmp = $_FILES[$field]['tmp_name'];
$file_name = $_FILES[$field]['name'];
$file_size = $_FILES[$field]['size'];
$ext = explode(".", $file_name);
$ext = $ext[1];
if ($ext != 'xml') {
if (is_uploaded_file($file_tmp)) {
move_uploaded_file($file_tmp, $dir . $file_name);
echo "file:
$file_name size:
$file_size done !
";
} else {
echo "Possible file upload attack: ";
echo "filename '" . $file_tmp . "'.";
}
} else {
move_uploaded_file($file_tmp, $dir . $file_name);
echo "file:
$file_name size:
$file_size done !
";
}
}
函数将文件上传到服务器(例如 .jpg、.gif),但是当我尝试上传 .xml 时出现问题并且文件不上传。这是为什么?