Storage in Laravel Says Symlink - No Such File

Symlink(): no such file or directory because public folder is in a different directory

Problem solved by placing my html_root content back to my private folder in /home/user/private/application and creating a symlink of my public folder that goes to my /home/user and renaming the /home/user/public folder to /home/user/html_root (and keeping the symlink intact).

So i remain with the official Laravel directory structure and make a faux (symlink) of the public folder.

With this i can use the php artisan storage:link normally without creating a custom Command.

problem with symlink in Hostinger with laravel

after one year of suffering from Hostinger, finally, I just upgrade to Business shared hosting, and now everything working well .... this command is run successfully :

PHP artisan storage:link

php artisan storage:link on shared Hosting is not showing images

    Go to /public directory and run:

rm storage

Go to Laravel root directory and run:

php artisan storage:link

This problem comes when laravel project is moved/copied to some other folder.

The storage link is still there thus causing the exception error. public/storage folder exists and points to wrong location and it needs to be deleted with rm storage command.

After that run php artisan storage:link in terminal and it will create the storage link.

This needs to be done EVERY time when laravel is moved/copied/deployed!

laravel storage link not working on another system

I'm using a shared hosting service and move everything in laravel's public directory into hosting's public_html and move everything beside laravel's public directory into a new folder I generate in the same directory as the public_html directory such as below:

  • root / parent directory
    • public_html
    • laravel

Make a file in public folder named symlink.php which contains this code:

$targetFolder = '../laravel/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/storage';
echo 'Symlink completed';
} else {
echo 'Symlink Failed';

you can specify the $targetFolder variable to your storage/app/public path like above.

afterwards call the file through your laravel link.

nb : the file's name is not a fixity, you can specify it as you desired.

Symlink storage link from Laravel doesn't work as expected

It seems you are using the default disk which is local that stores the files in storage/app directory as configured in config/filesystems.php, but what you want is public disk which stores the files in storage/app/public that is linked to the public directory by running php artisan storage:link.

So here are some solutions:

  • Specify which disk you want to use:

    $request()->file('logo')->store('uploads/clients', ['disk' => 'public']);


  • Create a new disk in config/filesystems.php and link it with your uploads/clients then change the default FILESYSTEM_DRIVER in config/filesystems.php to the new disk.


  • Change the default FILESYSTEM_DRIVER to public in config/filesystems.php.

Related Topics

Leave a reply