对于我的laravel api,我在json中返回一个包含标题和图像链接的对象。
但在laravel中,我不知道在哪个文件夹中以及如何返回将在移动应用程序上显示的图像的完整链接。
数据保存在mysql数据库中
示例:
{
"title" : "example",
"image" : "http://www.example.com/images/example.png"
}
谢谢你的帮忙
我添加了一条要测试的路由:
Route::get('v1/pictures/{filename}',function($filename){
return asset('/storage/app/public/images/'.$filename);
});
当我调用:http://localhost:8000/api/v1/pictures/chat1.jpg时,我得到:http://localhost:8000/storage/app/public/images/chat1.jpg
但是当我转到这个链接时,我有一个没有找到的错误:对不起,找不到你要找的页面。
发布于 2018-06-06 04:59:42
echo asset('/storage/app/public/images/example.png');
这应该是类似这样的回音
yourpage.com/storage/bla/bla/example.png
https://stackoverflow.com/questions/50708560
复制相似问题