@Christiaan put file (files) in project path and no problem
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?
@Agelios i just neeed to acces some file from PC/localnetwork, i can't put it in Project.
@Christiaan in config filesystems.php add new disk. And set your root. And then
Storage::disk('youNewLocalDisc')
it shoud be fine
@Agelios soo i can access then disk C:, D: ...
@Christiaan yes
@Agelios can you please give an example ?
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'));
});
@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?
map a drive letter in your OS and do as suggested
@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 ?
'ws-1-d' => [
'driver' => 'local',
'root' => 'N:\\WS-1-D',
],
You can then use 'ws-1-d' as a named disk in the storage facade.
Sooner or later you should read the docs where it is all explained.
https://laravel.com/docs/5.6/filesystem#obtaining-disk-instances
@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.