Search code examples
laravellaravel-8symlink

Laravel: show images which are outside of root directory


I need to display a series of images that are outside the root directory.

I've been reading about creating a symbolic link but I can't get my head around it at all.

In the filesystems.php file, the disk pointing to that directory is:

'communication' => [
    driver' => 'local',
    'root' => '/var/www/communication',
],

'links' => [
    public_path('storage') => storage_path('app/public'),
],

What I think I should make is a symbolic link pointing from "/var/www/communication" to "app/public" but it's not clear to me at all.

Please, could someone help me or guide me with this issue?

Thanks in advance.


Solution

  • In your app/public you need to create a symbolic link to /var/www/communication

    ln -s /var/www/communication communication
    

    Your app/public/communication now points to /var/www/communication.

    'communication' => [
        'driver' => 'local',
        'root' => public_path('communication'),
    ]