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

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

问题描述

我是 Laravel 的新手并试图存储私人图像,以便只有经过身份验证的用户才能访问它们.首先,我将图像存储在 Public/UserImages 文件夹中.但在这里,未经身份验证的用户也可以访问所有图片,方法是转到 Inspect Element of chrome 然后更改用户 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天全站免登陆