Directory Structure

Image Upload Service

In this video lesson we will be setting up Laravle's storage folder to connect to our public directory. In addition we will be generating our configuration files to separate our full images with our thumbnails.

Video Information

Hi everyone , welcome back to Laracademy. It's Mickey again and in this video we are going to work on our directory structures. We want a way to save our images cleanly. This mean splitting up our thumbnails and images. I am not super worried about reaching the maximum number of files within a directory so I am going to keep this pretty simple.

Let's open up config/filesystems.php and scroll to the bottom. We will want to create two new entries. Let's duplicate the public array twice and make some minor changes.

'images' => [
  'driver' => 'local',
  'root' => storage_path('app\images\\'),
  'url' => env('APP_URL').'/storage/images',
  'visibility' => 'public',
],

'thumbnails' => [
  'driver' => 'local',
  'root' => storage_path('app\thumbnails\\'),
  'url' => env('APP_URL').'/storage/thumbnails',
  'visibility' => 'public',
],

We will be using the Storage class to access these keys. Basically Laravel is setting up a route for us to easily access things in these directories. We are using the storage_path helper function which means that we need to link our storage area up to our publically accessible area. We can do this with an artisan command.

php artisan storage:link

Now if we look in our public directory we should have a new folder called storage. This folder is just a symbolic link to the storage/app/public directory. So any file that we place in here, will automatically be propigated to the public directory. We can show this by making a new file in the storage directory and then checking out the public directory.

We have now completed the directory setup and in the next video we will be checking out the html code that was included in the original branch. Thanks for watching and I will see you in the next video

Do you have a question? Go ahead and ask it below.

Please login to ask your question