公共目录(index.php所在的位置)文件存储错误

问题描述 投票:0回答:1

我面临一个问题,我的机器上有一个工作代码,但是当我启用它时,它给出了错误,如下所示 Symfony\Component\HttpFoundation\File\Exception\FileException: 无法写入“/app/public /media”目录。在文件 /app/vendor/symfony/http-foundation/File/File.php 第 131 行

这是我用来上传文件的代码

       if (!File::isDirectory($directory)) {
            File::makeDirectory($directory, 0755, true, true);
        }

        $file = $request->file('file');
        $fileName = time() . '_' . $this->cleanString($file->getClientOriginalName()); // You can customize the file name if needed
        $file->move(public_path('media'), $fileName);

这段代码在本地机器上运行良好,但在现场运行时不行,我正在为 laravel 使用 kinsta 应用程序,我不想使用 laravel 存储目录,但它不起作用,有人可以看一下吗

还有视频链接(视频时间2分钟):https://drive.google.com/file/d/1OU65PXYrZaL3pJkDcpAqXfHoy8emN38s/view?usp=sharing

laravel makefile storage kinsta
1个回答
0
投票

只需运行以下命令

chmod -R 777 public
© www.soinside.com 2019 - 2024. All rights reserved.