php - laravel how to deal with the problem that users can only access the pictures they uploaded
阿神
阿神 2017-06-10 09:47:27
0
3
706

How to deal with laravel users can only access the pictures uploaded by themselves

阿神
阿神

闭关修行中......

reply all(3)
仅有的幸福

First of all, the uploaded pictures must be marked with which user uploaded them. This can be stored in the database.
In fact, you can write a middleware for accessing images. Before actually accessing the image, you can determine whether the image belongs to the current accessing user, and then provide different processing

小葫芦
  1. Record the user who the picture belongs to

  2. Judge before accessing. Add middleware to the controller that accesses the image.

黄舟

First of all, you can only view the pictures you uploaded. What is the difference between it and the photo album?
You create a table and save the user and attributes corresponding to the image
Then use the middleware to determine whether the user this image belongs to is the current logged-in user

When you click on the picture, you will definitely get the picture ID or something, and then check the user ID and compare it with the currently logged-in user. If it is inconsistent, just return false!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template