2016-10-30 81 views
1

我有一個關於Laravel的問題,File::put()存儲在Laravel中?Laravel中存儲的File :: put()在哪裏?

我檢查了storage/app/public,內容不存在。

+0

你嘗試過'Storage :: disk('local') - > put('file.txt','Contents');'。這會將文件存儲在storage/app/file.txt中。 –

回答

0

存儲文件夾中storage/app,你必須使用Storage類爲:

Storage::disk('local')->put('file.txt', 'Contents'); 

那就一個文件存儲在storage/app/file.txt

Docs

+0

這是我正在尋找的解決方案。謝謝。 –

1

File::putpublic文件夾

例如。在這種情況下file.txt的將公共文件夾中創建

File::put('file.txt', 'contents is written inside file.txt'); 

您也可以使用存儲類

Storage::put('file.txt','contents is written inside file.txt'); 

這將在裏面創建文件storage\app

1

,以確保該位置,您可以使用的功能

  • public_path()
  • storage_path()
  • APP_PATH()

例如:

File::put(public_path('uploads'));