失败的上传脚本

时间:2013-07-21 12:44:33

标签: php upload uploading

我有一个PHP脚本,我用它上传。在我切换到另一台服务器之前,但现在却没有。这是PHP文件:

<?php
if($_FILES["file"]["error"] > 0){
    echo "There was an error processing your upload. Please try again. ";
}else{
    // Save this file in the directory
    move_uploaded_file('$_FILES["file"]["tmp_name"]', '"uploads/".$_FILES["file"]["name"]');
}
?>

我不仅在error.log中收到此错误:

[Sun Jul 21 12:32:34 2013] [error] [client 10.127.2.10] PHP Warning:  

move_uploaded_file(uploads/file.
txt): failed to open stream: Permission denied in /home/liongold/Web/upload_script.php on line 6, referer
: http://url/upload_page.html
[Sun Jul 21 12:32:34 2013] [error] [client 10.127.2.10] PHP Warning:  move_uploaded_file(): Unable to mov
e '/tmp/phpa0hsMc' to 'uploads/file.txt' in /home/liongold/Web/upload_script.php on line 6, referer: h
ttp://url/upload_page.html

1 个答案:

答案 0 :(得分:0)

这可能是因为许可问题。目录“uploads”必须具有上传到该目录的写权限。

转到您的控制台并将目录权限设置为777。

我希望它能解决你的问题。