How to deal with laravel users can only access the pictures uploaded by themselves
仅有的幸福2017-06-10 09:49:27
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
高洛峰2017-06-10 09:49:27
Record the user who the picture belongs to
Judge before accessing. Add middleware to the controller that accesses the image.
黄舟2017-06-10 09:49:27
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!