关于php:警告:move_uploaded_file():copy()函数的第二个参数


Warning: move_uploaded_file(): The second argument to copy() function

我正在研究文件上传方法。 但是我突然开始出现以下错误,我唯一更改的是文件名。 我将其还原,但错误仍然存在。

有谁知道如何解决这个问题?

错误消息是:

Warning: move_uploaded_file(): The second argument to copy()
function cannot be a directory in
/hermes/bosnaweb14a/b1717/ipg.plantationkeyartcorn/kittyrescuetnr/docs/upload.php
on line 13

Warning: move_uploaded_file(): Unable to move '/tmp/phpJki8OC' to '/' in
/hermes/bosnaweb14a/b1717/ipg.plantationkeyartcorn/kittyrescuetnr/docs/upload.php
on line 13
Fail

我的PHP看起来像这样

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$file_upload="true";
$file_up_size=$_FILES['file_up'][size];
$file_destination=$REQUEST['file_type'];
$file_new_name=$REQUEST['file_name'];


$file_name=$_FILES[file_up][name];
**$add="$file_destination/$file_new_name"; // the path with the file name where the file will be stored**

if($file_upload=="true"){

if(move_uploaded_file ($_FILES[file_up][tmp_name], $add)){
echo print_r($file_new_name);
}else{echo"Fail";}

}else{
echo $msg;
}

 ?>

好吧,由于您错误地使用了超全局数组$_REQUEST(请注意名称中的下划线),因此您的$add变量的计算结果只是一个斜杠。 这是一个根目录。

因此出现了错误-毕竟这是一个目录,并且您的脚本可能仍然没有对该目录的写权限(这是一件好事)。