Storage in laravel says symlink - no such file

Solution 1:

  1. Go to /public directory and run:

    rm storage

  2. Go to Laravel root directory and run:

    php artisan storage:link


Edited on May 1st 2018

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!

Solution 2:

I'm face same error when use share hosting and my public directory move to public_html or different directory like : project directory in root name "project" and public directory in root name "public_html"

when run artisan command by Artisan::call('storage:link'); then face this error.

Solution: 1st need to bind your public directory in app/Providers/AppServiceProvider register method

 $this->app->bind('path.public', function() {
    return base_path('../public_html');
 });

Now run the command its working fine

Solution 3:

Just in case your down here still without an answer.

I had trouble because I did the symlink locally, then copied the files to the server. In order to make it work I did the following:

$  cd path/to/laravel/root

// if public does not exist, first create it.
$  cd public

// if public/storage does not exist, first create it.
$  rm -r storage

$  cd ..

// Now it should work
$  php artisan storage:link 

Solution 4:

This usually happens after moving Laravel app to another directory

The actual storage directory is "/AppName/storage/app/public/"

Laravel creates a symbolic link pointing to actual storage dir "/AppName/public/storage"

Other meaning

"/AppName/public/storage" points to => "/AppName/storage/app/public/"

On changing root app directory to "/AnotherAppName/" symlink will still point to the old path

"/AnotherAppName/public/storage" => "/AppName/storage/app/public/"

my solution is to manually update the symlink using

ln -sfn /AnotherAppName/storage/app/public/ /AnotherAppName/public/storage

Solution 5:

Anyone coming in the future using Laravel Forge. I had this error when I renamed my domain name in Forge.

storage:link error

The solution was to go into the public directory and delete the existing symlink which had been copied over from the original domain.

public symlink to storage

After this symlink had been deleted, I was able to run php artisan storage:link again and this worked correctly.