问答详情
源自:1-3 $_FILES预定义变量解析

permission denied

报错如下

Array ( [myFile] => Array ( [name] => gray_level.jpg [type] => image/jpeg [tmp_name] => /Applications/XAMPP/xamppfiles/temp/phpmx8Qdu [error] => 0 [size] => 69150 ) ) 
Warning: move_uploaded_file(images/gray_level.jpg): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/php/doAction.php on line 12

Warning: move_uploaded_file(): Unable to move '/Applications/XAMPP/xamppfiles/temp/phpmx8Qdu' to 'images/gray_level.jpg' in/Applications/XAMPP/xamppfiles/htdocs/php/doAction.php on line 12

upload.php

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
	<title>上传文件</title>
</head>
<body>
<form action="doAction.php" method="POST" enctype="multipart/form-data">
	选择你要上传的文件
	<input type="file" name="myFile" /><br / >
	<input type="submit" value="上传文件" />
</form>
</body>
</html>

doAction.php

<?php

print_r($_FILES);
$fliename = $_FILES['myFile']['name'];
$type = $_FILES['myFile']['type'];
$tmp_name = $_FILES['myFile']['tmp_name'];//上传的文件作为临时文件放在某个目录下
$size = $_FILES['myFile']['size'];
$error = $_FILES['myFile']['error'];

//将服务器上的临时文件移动到指定目录下
//move_uploaded_file($tmp_name,$destination)
move_uploaded_file($tmp_name, "images/".$fliename);
copy($tmp_name, "images/");
?>


提问者:Charlotte0 2016-02-22 18:54

个回答

  • 慕前端7121920
    2016-02-22 23:38:23

    你都已经移动了,还去拷贝文件干嘛