我可以上传图片并在存储/应用 /(abc.jpg)中查看图片
并设置 'root'=> filesystems.php中的storage_path('app'),
account.blade.php
<img src="{{ route('account.image', ['filename' => $user->user_id . '.jpg']) }}" alt="" class="img-responsive">
routes.php文件
Route::get('/userimage/{filename}', [
'uses' => 'UserController@getUserImage',
'as' => 'account.image'
]);
控制器
public function getUserImage()
{
$file = Storage::disk('local')->get($filename);
return new Response($file, 200);
}
GET http://localhost:8000/userimage/00bea23ff9dd07e5b175c0f8a9283ca8.jpg 500(内部服务器错误)
答案 0 :(得分:2)
在你的控制器方法中你需要像这样定义$ filename ......
public function getUserImage($filename)