【发布时间】:2020-04-29 09:43:18
【问题描述】:
我有这个代码:
public function showImage($id) {
$item = File::find($id);
return response()->file($item->file_name_and_path);
}
$item->file_name_and_path 包含以下内容:
files/2020/04/29/myfile.jpeg
现在我总是收到FileNotFoundException。
图片文件在本地驱动的这个路径中:
{laravel root}/storage/app/files/2020/04/29/myfile.jpeg
我怎样才能获得正确的本地路径或简单地返回带有图像 HTTP 标头的图像文件?
【问题讨论】:
-
使用
return response()->with('Image_path',$item->file_name_and_path); -
你需要文件路径还是文件url?
标签: laravel laravel-6 laravel-storage laravel-filesystem