警告:move_uploaded_file(myfiles / img.png):无法打开流:权限被拒绝

时间:2017-07-17 18:50:31

标签: php .htaccess

您好我在localhost上传文件时遇到了一些问题。我正在使用XAMPP。我查看了php.ini并确保file_uploads = On,但警告不会消失,文件也不会上传。此外,我试图在没有运气的情况下查看其他一些具有相同主题的页面。

我的错误:

Warning: move_uploaded_file(myfiles/img.png): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/website/changethesettings.php on line 118

Warning: move_uploaded_file(): Unable to move '/Applications/XAMPP/xamppfiles/temp/phpRGfg7t' to 'myfiles/img.jpg' in /Applications/XAMPP/xamppfiles/htdocs/website/changethesettings.php on line 118

这是我的HTML:

<form method="post" action="changethesettings.php" enctype="multipart/form-data">
<input id="file" type="file" name="file"/>
<input type="submit" value="submit file"/>
</form>

这是我的PHP代码(changethesettings.php):

        $target_dir = "myfiles/";
        $target_file = $target_dir . basename($_FILES["file"]["name"]);
        $uploadOk = 1;
        $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

    -> line 118    if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
            echo "The file ". basename( $_FILES["file"]["name"]). " has been uploaded.";
        } else {
            echo "Sorry, there was an error uploading your file.";
        }


die("<br> the end");

应该提到我有一个.htaccess。我不知道这可能是警告的原因:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

Options -Indexes

由于

0 个答案:

没有答案