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

christiann's avatar

Access an local disk with Laravel

Hi there, the question is: How can i access a local disk on my PC with Laravel? If i use: Storage :: disk ('C:') it does not work. Can anyone help me with that?

0 likes
12 replies
christiann's avatar

@Agelios i just neeed to acces some file from PC/localnetwork, i can't put it in Project.

Agelios's avatar

@Christiaan in config filesystems.php add new disk. And set your root. And then

  Storage::disk('youNewLocalDisc')

it shoud be fine

lostdreamer_nl's avatar

Setup you filesystem config with a c-drive pointing to c:\ (also an extra \ for escaping) and use the Storage::disk() with the key you setup in the config file.

config/filesystems.php:

<?php

return [

    'default' => env('FILESYSTEM_DRIVER', 'local'),

    'cloud' => env('FILESYSTEM_CLOUD', 's3'),

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],
        'c-drive' => [
            'driver' => 'local',
            'root' => 'C:\\',
        ],
    ],

];

routes/web.php:

Route::get('test', function() {
    dd(Storage::disk('c-drive'));
});
1 like
christiann's avatar

@lostdreamer_nl thx, but what if disk is not local ? What if this is in intranet and i can access it from PC how can i access it with laravel?

Snapey's avatar

map a drive letter in your OS and do as suggested

christiann's avatar

@Snapey for example when i access an driver browser i give this path:

file:///N:/WS-1-D/ how can i do it in laravel ?

christiann's avatar

@Snapey i tried it, it doesn't work i am getting this error :

Impossible to create the root directory "N:\WS-1-D".

Please or to participate in this conversation.