移动上传的文件 - 没有权限

时间:2013-02-27 17:42:49

标签: php linux apache upload

上传文件时我一直收到权限错误。

警告:move_uploaded_file(/var/www/localhost/htdocs/trade-show/documents/hero_front.jpg)[function.move-uploaded-file]:无法打开流:/ var / www / localhost中的权限被拒绝第30行/htdocs/trade-show/selectItems.php

这是我的代码。让它工作的唯一方法是通过制作目录权限777.我已经尝试了chmod 0755而没有运气。想法?

if ($_FILES['fileUpload']['error'] == 0) {
    $upload = "/var/www/localhost/htdocs/trade-show/documents/".basename($_FILES['fileUpload']['name']);

    if (!move_uploaded_file($_FILES['fileUpload']['tmp_name'],$upload)) {
        echo "<h1>Error uploading file ".$_FILES['fileUpload']['name']."</h1>$upload<br />\n";
    } else {
        move_uploaded_file($_FILES['fileUpload']['tmp_name'],$upload);
    }
}

0 个答案:

没有答案