Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

Symlink not working on windows

Hello,

My symlink does not work out correctly. I already type: php artisan storage:link

As I place an image in storage/app/public/slides/random-image.jpeg , my public/storage folder remains empty.

Any clue why?

0 likes
23 replies
rfountain's avatar

Can you try removing your public/storage directory and try running storage:link again? Is it possible that the public/storage directory already existed before?

1 like
douglasakula's avatar

Probably permissions for the public/storage folder that do now allow for files to be created in the directory

Tray2's avatar

Windows does not have symlinks. They have something similar. I suggest you use a virtual machine running a linux distribution (Ubuntu, CentOs or similar) to host your site. Then you will have a environment that is quite close to the production environment.

Here is a guide for Ubuntu

https://www.howtoforge.com/tutorial/ubuntu-laravel-php-nginx/

2 likes
davy_yg's avatar
Level 27

Can you run php artisan storage:link ? Will it works on Windows?

I don't like using virtual machine to code. I normally code my laravel projects on Windows localhost and they work just fine.

I already checked the public/storage/slides permission. It is write permissable.

Is reading the the public/storage folder is requirements for storage? Can you not read it directly from the storage/app/public/slides folder?

Nakov's avatar

They work just fine until they don't :)

are you working just for yourself, meaning only local projects or do you ever deploy your projects on a production server for other people to use them?

The advice above is great if you deploy your projects as most of the servers are unix based, so having same environment benefits you 100% of the time.

If you still want to run on Windows, take a look at this answer on how to create the symlink

https://github.com/laravel/framework/issues/15439#issuecomment-408036822

davy_yg's avatar
Level 27

I successfully created the symlink. Yet, when I upload a new image and delete the old one, the new image is not mirror to the public/storage and the old still remains. I thought it would be a complete mirror of storage/app/public folder?

Is creating the public/storage directory necessary seems, I can still read the image directly from the storage/app folder and it works!

Nakov's avatar

As I said above, if you are using the projects only for local development, then do it however it works 😁

it won't work once you deploy on a server. But you don't want to have a production like environment anyway, so again, do whatever it works for you.

We are here to give an advice, not to convince you to do it the proper way.

davy_yg's avatar
Level 27

Thanks for advice, I would like it to work even after I upload it to the server.

And I still have this problem: when I upload a new image and delete the old one, the new image is not mirror to the public/storage and the old still remains. I thought it would be a complete mirror of storage/app/public folder?

Is the command that I write in gitbash works just like in Linux environment?

Nakov's avatar
Nakov
Best Answer
Level 73

The public/storage is a mirror of storage/app/public not vice versa. So it depends on how and where do you delete the image from. Showing code is always better then theory.

Also when you say you delete it, can you still see the image on a page, even after you delete it, or you just see it in the system?

davy_yg's avatar
Level 27

PageController.php

public function store_home_slides(Request $request)
    {

...

 $slides = HomeSlidesModel::find($id);
    $file = $request->file('slides');
        
    if($file)
    {
        
        //storage/app
        Storage::delete($slides->image);
        
        //storage/app/slides/random.jpeg
        $path = $request->file('slides')->store('public/slides');
        
        Log::info('path :'.$path);

        Session::flash('flash', 'Successfully save data');

    }

    $slides->title = $request->title;
    $slides->image = $path;

    $slides->update();

This is my delete code and how I save the path to the database.

When I deleted the image, it means I delete the old image and create the new one. To be accurate, this is an edit image feature.

Nakov's avatar

@davy_yg my other question was how do you know that the delete works at all? Is it deleted from one place only and still shows in the other folder?? Is the image still visible on the page after it is being deleted??

Not having your environment nor your code it is hard to predict or tell what is going on, you need to debug yourself..

davy_yg's avatar
Level 27

The delete does works since it only delete from my storage/app/public folder. The new image also appears in this folder after I uploaded the new image. Yet, it still remains in public/storage folder.

I basically only need the logic or the algorithm.

Do I have to delete and upload the image in both folders? Since the image only mirror after I type this command:

Admin@LAPTOP-HTFI5LEL MINGW64 /d/xampp72/htdocs/aws_admin_test

ln -sr storage/app/public public/storage

Yet, it is not continously mirror.

Nakov's avatar

You should delete from one place only, the storage folder. Now why the symlink does not work on Windows I really don't know. You can google that I guess.

davy_yg's avatar
Level 27

D:\xampp72\htdocs\aws_admin_test>mklink /J storage/app/public public/storage Invalid switch - "app".

I am not familiar with linux. Is this not possible in Windows?

Check this tutorial: https://github.com/laravel/framework/issues/15439

Any clue what the last comment means?

type: "nfs"
  mount_opts: ['nolock,vers=3,udp,noatime,actimeo=1']
siangboon's avatar

D:\xampp72\htdocs\aws_admin_test>mklink /J public\storage storage\app\public

davy_yg's avatar
Level 27

Hey, it finally works!

php artisan storage:link

I just have to check the public/storage file from explorer not through sublime. My sublime does not show what is inside the storage symlink folder.

1 like
melih's avatar

Thank you @davy_yg! Owing to this discussion I've realized that the storage inside public folder in my project is a real directory instead of a shortcut.

tahmid2012's avatar

@davy_yg hello, I am facing same problem on windows. Can you tell me details about that solution ? please

wilfredofermin's avatar

The problem is when using windows

solution:

In my case, I am using laragon.

LINK CREATION (This is because the php artisan storage: link does not work on windows)

  • For this case, you will have access to images
  • Open cmd as administrator
  • Verify that public access does not work (public \ images)
  • Then copy: mklink / J C: \ laragon \ www \ project-name \ public \ images C: \ laragon \ www \ project-name \ storage \ app \ images

This would be similar to: php artisan storage: link

Take into account that to save in images it must be configured in the filesytem file (conf / filesytem)

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

tahmid2012's avatar

@davy_yg hello, I am facing same problem on windows. Can you tell me details about that solution ? please

pauloacosta's avatar

You probably created the symlinks in Linux and then copied the files to Windows. I had the same problem! The solution was to delete the symlinks created in Linux (in my case, created in the docker) and then run the "php artisan storage:link" command to recreate the Windows symlinks.

Please or to participate in this conversation.