2015-11-07 36 views
2

我目前在Laravel的學習曲線。 我想知道是否有方法使用Laravel中的Storage::從另一個硬盤(使用Windows)訪問文件。PHP Laravel從另一個驅動器讀取文件

例如,我已經在驅動器C:上安裝了Laravel的Xampp,但是我想訪問E:網站目錄之外的文件。我試過使用Storage::files('E:')File::files('E:')但這顯然不起作用。

在此先感謝。

回答

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:的鏈接。

+0

這是完美的作品。剛剛測試過它。 沒想到我必須將驅動器添加到配置中。但那是有效的。 謝謝! – Kaizokupuffball

+0

@Kaizokupuffball我覺得我比你更快樂! :) –

相關問題