Laravel 3-如何在ubuntu服务器中安全存储用户数据 [英] Laravel 3 - how to securely store user's data in ubuntu server

查看:45
本文介绍了Laravel 3-如何在ubuntu服务器中安全存储用户数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Web应用程序中,用户可以上传其个人资料图片.他们可以在线销售手机,因此也可以上传手机图像,但是如果我将个人资料图片和手机照片存储在mylaravel-app/public/(css js images user-photos)中,则每个其他用户也可以看到这些照片.

In my web application, a user can upload their profile picture. They can sell their mobile online, so they can also upload images of their mobile, but if I store profile picture and mobile photos in mylaravel-app/public/(css js images user-photos) then every other user can see those photos as well.

我应该如何将照片存储在另一个目录中,这样只有用户才能看到他们的照片,而且用户也不能从url中看到整个照片目录,例如:

How should I store the photo in another directory so that only the user can see only their photos, and also user must not be able to see whole directory of photos from url like:

      `site.com/photos (whole directory is exposed )` 

推荐答案

一种方法是为每个用户提供自己的照片文件夹,因此,如果用户ID为1,则其目录为mylaravel-app/public/photos/userid,然后将与照片匹配的用户ID放在数据库的单独表中.您也可以chmod文件夹,以便只有应用程序可以访问照片目录.这是有关此的文章: 文件权限

One way to do this would be to give each user their own folder for photos, so if a user id was 1, their directory would be mylaravel-app/public/photos/userid, then put the user id that matches up with the photos in a separate table in the database. You can also chmod the folder so only the application can access the photo directory. Here is an article for that: File Permissions

这篇关于Laravel 3-如何在ubuntu服务器中安全存储用户数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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