I want to be able to serve a file, located at any path on the server's filesystem that PHP/Apache has permission to read, as if it was in Laravel's public folder.
Let's say I have a local directory on my server /var/directory/ that contains two files:
/var/directory/abc.jpg/var/directory/xyz.jpg
Now, how can I make these files accessible via something like:
https://example.com/media/abc.jpghttps://example.com/media/xyz.jpg
I think I need a controller that handles routes for /media/{filename}. It's fairly straight forward to then check if said file exists on disk in /var/directory/ and read it into PHP.
So the real question is: how I read these files efficiently and then serve them as a response to a get request? The solution should be as efficient as possible so that it works for larger files (10s to 100s of MB).