我在storage->app->upload->images->1472803410756.jpg上有一张图片。当我键入url http://localhost:8012/demo/storage/app/upload/images/1472803410756.jpg时,浏览器会准确地显示我的图像。但是运行php artisan serve,url:http://localhost:8000/storage/app/upload/images/1472803410756.jpg浏览器没有找到我的图像。怎么才能修好呢?
我的html代码:
<td><img class="table_image" src="{{asset("storage/app/upload/images/$product->product_image")}}"></td>发布于 2017-04-17 11:50:08
这是错误的,您从仅具有写权限的存储folder.Because存储文件夹中获取映像。因此,首先您需要创建存储路径的路由。
enter code here
Route::get('storage/{filename}', function ($filename)
{
$path = storage_path('app/upload/images/' . $filename);
if (!File::exists($path)) {
abort(404);
}
$file = File::get($path);
$type = File::mimeType($path);
$response = Response::make($file, 200);
$response->header("Content-Type", $type);
return $response;
});在那之后,你的img标签看起来是这样的:-
<td><img class="table_image" src="{{url("storage/".$product->product_image)}}"></td>希望能帮上忙!
https://stackoverflow.com/questions/43450234
复制相似问题