I have upload area for my customers which files should be private and not public accessible. Because of non-public availability, how can I get this files for preview in application? Is there any other way to get it directly from server?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
If you are working with images:
Then in your view:
For any other file:
Your view:
If you wish you may use a controller:
Then your route definition would look like:
And your view:
Yes, you can serve files without making them public.
The basic idea is that you add a route which authorizes the request and then serves the file.
For example:
There are many built-in ways for serving files. Here are four that I would recommend looking at:
For files stored in an external system (like Amazon S3) that supports temporary URLs, it's sometimes better to generate a URL to the file instead of serving it directly from your application. You can usually do this with
Storage::temporaryUrl()
.