php move_uploaded_file返回true但localhost上缺少文件

时间:2017-10-25 14:38:19

标签: php

我正在尝试将一个图像移动到新文件夹 move_uploaded_file 返回1但文件丢失,我正在使用XAMPP的localhost

$name = basename($_FILES['arr']['name'][0]);
move_uploaded_file($_FILES['arr']['tmp_name'][0],"\Images");

2 个答案:

答案 0 :(得分:0)

$name = basename($_FILES['arr']['name'][0]);
move_uploaded_file($_FILES['arr']['tmp_name'][0],'/images/' . $filename);

您必须为要放置的文件添加目标,包括您要分配给它的文件名。

请参阅:http://php.net/manual/en/function.move-uploaded-file.php

答案 1 :(得分:-1)

您应指定目标文件名

if ( move_uploaded_file($_FILES['arr']['tmp_name'],dirname(__FILE__) . '/images/' . $_FILES['arr']['name'] ) ) {
    echo "file uploaded";
} else {
   echo "error in uploading";
}