【发布时间】:2019-05-07 03:45:00
【问题描述】:
我做了一个 youtube 风格的网站,有些人可能会点击视频成为私有,我将这些视频保存在 storage/app/vidoes/{channelname} 中,我工作的公共图像和视频不是问题,而是本地存储我有问题,有什么想法吗?
只是在缩略图上显示 404
谢谢
查看
<img src="{{ route('home.image', ['file_path' => 'videos/' . $video->channel_name . '/thumbnails/' . $video->video_thumbnail_name]) }}" alt="" class="img-responsive">
路线
Route::get('{file_path}', [
'uses' => 'HomeController@getImage',
'as' => 'home.image'
]);
控制器
public function getImage($filepath)
{
$fileContents = \Storage::disk('local')->get($filepath);
$response = \Response::make($fileContents, 200);
$response->header('Content-Type', "image/jpg");
return $response;
}
【问题讨论】:
标签: laravel