首页 > 解决方案 > mkdir 上的 file_put_contents 无法打开流:权限被拒绝

问题描述

我正在尝试从我开发的应用程序上传图像。我不断收到此错误failed to open stream: Permission denied

这是我在 PHP 5.6 上的代码

$target_dir = '../../uploads/temp/'.$username.'/'.$acad_year.'/'.$semester;

        if (!is_dir($target_dir))
        {
            mkdir($target_dir, 777, TRUE);
        }

        file_put_contents($target_dir, base64_decode($_POST['image']));

这是错误

file_put_contents(../../uploads/temp/asdasda/2019-2020/2nd): failed to open stream: Permission denied in <b>C:\xampp\htdocs\sfas\android_app\v1\UploadPicture.php</b>

我做了一些研究,但没有任何效果。

标签: phpphp-5.6

解决方案


推荐阅读