PHP Laravel从另一个驱动器读取文件

时间:2015-11-07 22:07:05

标签: php laravel directory

我目前正处于Laravel的学习曲线中。 我想知道是否有办法使用Laravel中的Options -> Configuration来访问来自另一个硬盘的文件(使用Windows)。

例如,我在驱动器C:上安装了Xrap和Laravel,但我想访问E:在网站目录之外的文件。我尝试过使用Storage::Storage::files('E:'),但这显然不起作用。

提前致谢。

1 个答案:

答案 0 :(得分:4)

我自己没有对此进行过测试,但是从文档页面开始,我需要将filesystem.php配置文件编辑为:

'disks' => [
    'local' => [
        'driver' => 'local',
        'root'   => storage_path('app'),
    ],
    'partitionE' => [
        'driver' => 'local',
        'root'   => 'E:/', // not really sure about this
    ]
    // the rest of it
];

然后访问

等文件
Storage::disk('partitionE')->put('file.txt', 'Contents');

如果所有这些都失败了,您可以使用symlink并在项目文件夹中创建指向E:的链接。