2016-11-29 70 views
0

我使用laravel Filesystem存儲圖像,圖像會默認存儲內被上傳,例如:Laravel 5.3存儲無法找到上傳的文件

/家庭/用戶/項目/ mywebapp /存儲/程序/圖片/職位/ 1/e392e17926559e7cc4e7934f.png

我沒有改變config/filesystem.php這裏是我上傳的圖像控制器的方法,

public function storeImage(Request $request) { 
    $image = $request->file('image')->store('images/posts/'.Auth::user()->id); 
    echo Storage::url($image); // <- print the url of the uploaded image 
} 

這將打印圖像的URL這樣,

http://localhost:8000/storage/images/posts/1/e392e17c6a8d7926559e8e7cc4e7934f.png

但是圖像文件不會從瀏覽器accessable! 我不想使用PHP動態獲取圖像,我只是想讓他們公開http訪問。如何顯示圖像?

回答

1

你就必須使配置\ ​​filesystems.php的形態的變化

'default' => local, 

'default' => public,

然後在控制檯運行php artisan storage:link

然後嘗試上面的代碼,它會工作

+0

哇!謝謝你 – rakibtg

+0

@rakibtg你永遠是受歡迎的... –