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

Ligonsker's avatar

Is it possible to create a symlink to a folder inside a network folder?

Hello,

Storing some images in a network drive folder N:/images and I want to be able to view them as publicly accesible images (to be used as img src).

Is it possible to do something similar to php artisan storage:link just to a specific path on a network drive?

Or I will need to use another method?

Thanks

0 likes
10 replies
vincent15000's avatar

It depends on the 3-party service you are using to store the images.

1 like
Ligonsker's avatar

@vincent15000 thank you, It's not a 3rd party service but just the way someone else here decided to store the images. (It's a network drive inside the corporation)

Should I then copy the images from the network drive folder to somewhere in public/? Or create a symlink from the network drive to the folder in laravel via the OS?

1 like
vincent15000's avatar

@Ligonsker Create a symlink from the network drive to point to the Laravel folder is not a good idea.

1 like
Ligonsker's avatar

@vincent15000 So the only safe option is to basically make copy of the images stored in the network drive to a public folder in Laravel?

newbie360's avatar

@Ligonsker If you are not run php artisan storage:link in VM

just edit filesystems.php add a new disk, and at the bottom add

    'links' => [
        public_path('storage') => storage_path('app/public'),
        public_path('the-folder-name')) => 'absolute-path',
    ],
1 like
Ligonsker's avatar

@newbie360 thanks, I did it, but it doesn't create the symlink, i.e. I don't see the-folder-name. I only see the storage folder symlink created inside /public, however the one with the path to the network drive won't work - could that be permissions issue?

1 like
newbie360's avatar

@Ligonsker If the app is inside VM and your don't give permission to the VM full controll the host file system

so you can't run php artisan storage:link inside VM

if your app is in the Windows host system, ensure the-folder-name is NOT exists in the public directory, and try run CMD as Administrator, and input

mklink /J "C:\your-project\public\the-folder-name" "N:\images"

// or

mklink /J "C:\your-project\public\the-folder-name" "\\network-path"

let see any error, for more information, google search windows mklink, the command has /D /H /J flag

https://github.com/laravel/framework/blob/11.x/src/Illuminate/Filesystem/Filesystem.php#L352

1 like
vincent15000's avatar

@Ligonsker To create the folder name (where the images are stored), you have 2 solutions :

  • either you create it manually when you develop the application

  • or you create it dynamically via the code (create if not exists)

But the folder won't be created automatically if you don't do anything for that.

1 like
Ligonsker's avatar

I mean the symlink "folder" is not created. For example when I run the default php artisan:link then it creates the symlink in /public/storage - or it only does that for the default link?

I thought the following:

public_path('the-folder-name')) => 'absolute-path',

would create the the-folder-name automatically as symlink icon in the public folder just like it does when it creates a synlink icon for storage (The default link)

newbie360's avatar

@ligonsker one more things, if your want delete the symlink

you can via Windows File Expoler, right click on it and select delete

you can delete via command

rmdir the_symlink

but you SHOULD NOT use this command, this will delete all stuff in the target

// this command very danger

del the_symlink

Please or to participate in this conversation.