使用laravel在Vue中显示存储文件夹中的图像
我正在以下位置保存我的图像 存储/应用/公共/用户图像 它正在被保存,但当我在vue组件中检索它时,它抛出错误404 not found使用laravel在Vue中显示存储文件夹中的图像,laravel,vue.js,laravel-5,vuejs2,Laravel,Vue.js,Laravel 5,Vuejs2,我正在以下位置保存我的图像 存储/应用/公共/用户图像 它正在被保存,但当我在vue组件中检索它时,它抛出错误404 not found <img :src="`/storage/${post.img_path}`"/> 请提出建议 向控制器添加方法(例如,PostController): 将路由添加到routes/web.php: Route::get('/posts/{post}/image', 'PostController@file')->nam
<img :src="`/storage/${post.img_path}`"/>
请提出建议
PostController
):
routes/web.php
:
Route::get('/posts/{post}/image', 'PostController@file')->name('posts.image');
<img :src="`/posts/${post.id}/image`"/>
您能告诉我在最后一个参数中要传递什么吗?我在db img_upload/629806533.png中存储这样的路径,其中img_upload是文件夹,629806533是image@user3653474你指的是哪个参数?您应该在项目1上以
Storage::disk('local')->path('img_upload/629806533.png')
的形式传递此路径。/posts/${post.id}/image“/>在此图像中传递的内容参数图像不是参数,它只是我在路由中定义的URL的一部分:route::get('/posts/{post}/image'),'PostController@file')->name('posts.image');
Route::get('/posts/{post}/image', 'PostController@file')->name('posts.image');
<img :src="`/posts/${post.id}/image`"/>