如何在Laravel 5中处理私人图片? [英] How to deal with private images in laravel 5?

查看:59
本文介绍了如何在Laravel 5中处理私人图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Laravel的新手,他试图存储私有图像,以便只有经过身份验证的用户才能访问它们.首先,我将图像存储在Public/UserImages文件夹中.但在这里,所有图片也可以通过未经检查的用户访问chrome的Inspect Element,然后更改用户ID来访问.请帮我...

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,或者完全使用

It's really up to you. It'll need to be outside the public directory - I'd personally pick resources/uploads or storage/uploads, or store them off-server entirely using the 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 5中处理私人图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆