Search code examples
phpmysqllaravelfile-storage

How can I store and access images from a private folder within my application using Laravel?


What is the best way to store resumes and videos in a private folder within my application i.e. not in any public folder?

For example, I created a folder called media directly in my application root level (not in any public folder) and inside the media folder is a resumes folder and a videos folder.

I've successfully been able to store the uploads in those folders and in my database, the problem is I don't know how to access them now and display them in my blade files.

What's important is that I have 2 types of users in my application, jobseekers and employers. So obviously, how can I do this where only a logged in job seeker can see his own resume and videos (there will be 1 resume (required) and 3 videos per user maximum (optional)) and know one else's? Employers can see anyone's profile with resume and videos, that's fine.

I'm guessing I need to create a route and set up a controller, but I'm a little confused about how to do this exactly.


Solution

  • You can also use the storage folder to store and retrieve the images/ videos

    Storage::get('file.jpg');