I am new to Laravel and trying to store private images so that only authenticated users can access them. Firstly I stored images in Public/UserImages folder. But here all the pictures are accessible to unauthenticated users as well by going to Inspect Element of chrome and then changing the user IDs. Kindly help out me...

推荐答案

这真的要看你的了.它需要在public目录之外-我会亲自挑选resources/uploadsstorage/uploads,或者完全使用cloud filesystem support将它们存储在服务器之外.

Whatever you pick, you'll need a route that fetches the file and passes it along to the user after first checking that they have access.

Laravel相关问答推荐

密码确认在Livewire中不匹配

运行NPM Prod时出现VUE问题

在Laravel中URL中添加保护ID

如何正确使用 Spatie\Laravel Data 来获取数据?

Laravel 模型事件:delete() 不会从存储中删除文件

我的共享主机上的每个帖子请求都出现 503 服务不可用

Laravel 9 如何将 url 中的参数从一个控制器传递到另一个控制器?

如何在 Laravel 中填充以后执行的条件

给定的角色或权限应该使用 guard `` 而不是 `web`. -Laravel

Laravel Eloquent - 随叫随到的加密/解密数据

laravel 控制器中的全局变量

Laravel 5.4 存储:下载文件.文件不存在,但显然存在

路由模型绑定不起作用

在 Laravel 中下载后如何重定向?

如何处理 laravel 5 中的私有图像?

Laravel/Lumen 中两列之间的 SQL

Laravel Mail 发送Electron邮件但返回 false

如何判断 Laravel 集合是否为空?

Laravel 5 Auth注销不起作用

Laravel 5.1 date_format 验证允许两种格式