Laravel 9存储图像错误403禁止

发布于 2025-02-09 21:09:35 字数 709 浏览 1 评论 0原文

再会。 我已经处理了几天的问题,这在其他任何Laravel项目中都没有发生。 我使用角和离子(Angular)连接到托管Laravel 9项目的VPS。我已经运行了php手工艺品存储:link命令,并给出了对存储文件夹的许可775。

在相同的VP中,我有更多的Laravel项目,其中我以与此项目相同的方式上传图像

request() - > file('file'') - > store('public/'.Juph );

这成功保存了图像,我可以在存储文件夹中看到它。

现在,当我想从浏览器或图像所在路由的应用程序中查看时,它给了我错误403 Forbbiden,您无权访问此文档。 我使用的路由与此结构:

https://exampledomain.com/storage/1/exampleimg.png

但是如果我再次给它权限775,它已经显示出毫无问题的图像,但是上传的新图像将不会显示,并且将继续说403 Forbbiden您无权访问此文档。

我无法授予权限775,每次上传新图像时,因为它是一个将由数十个人处理的项目。

最奇怪的是,只有在 laravel 9 中,我才有这个问题,因为在我过去的项目中,Laravel 7、6、5.8所有项目上传图像,我只需要一次允许存储文件夹。

Good day.
I've been dealing with a problem for a couple of days that hadn't happened to me in any other Laravel project.
I use Angular and Ionic(angular) to connect to a VPS where my Laravel 9 project is hosted. I've already run the php artisan storage:link command and given permission 775 to the storage folder.

In this same VPS I have more Laravel projects where I upload images with Storage in the same way as in this project

request()->file('file')->store('public/'.$id);

This successfully saves the image and I can see it in my storage folder.

Now when I want to see from a browser or from the app that route where the image is, it gives me the error 403 Forbbiden You do not have permission to access this document.
The route I use is with this structure:

https://exampledomain.com/storage/1/exampleimg.png

But if I give it permission 775 again, it already shows the image without any problem, but the new images that are uploaded will not be shown and will continue saying 403 Forbbiden You do not have permission to access this document.

I cannot be giving permission 775 every time a new image is uploaded since it is a project that will be handled by dozens of people.

The strangest thing is that only in laravel 9 I have this problem because in my past projects laravel 7, 6, 5.8 all projects upload images and I only had to give permission to the storage folder once.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲墙角沉默 2025-02-16 21:09:35

更改.env文件

filesystem_disk = local

to

filesystem_disk = public

Change in .env file

FILESYSTEM_DISK=local

to

FILESYSTEM_DISK=public

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文