PHP警告:move_uploaded_file():无法移动' / tmp / phpgjqCAw'到'上传/ mypic.png'在第7行的/var/www/html/uploader.php中

时间:2016-06-05 09:57:57

标签: php

我是php的新手。我上传文件后收到以下错误。你可以告诉我下面代码出了什么问题:

PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpgjqCAw' to 'uploads/mypic.png' in /var/www/html/uploader.php on line 7

uploader.html

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

uploader.php

<?php

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

?>

0 个答案:

没有答案