Laravel API return link 图片
Laravel API return link to image
对于我的 laravel api,我 return 在 json 中 object 包含图像的标题和 link。
但在 laravel 中,我不知道在哪个文件夹中以及如何 return 将在移动应用程序上显示的完整图像 link。
数据保存在 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
但是当我转到此 link 时出现未找到错误:抱歉,找不到您要查找的页面。
echo asset('/storage/app/public/images/example.png');
这应该回应类似
的内容
yourpage.com/storage/bla/bla/example.png
对于我的 laravel api,我 return 在 json 中 object 包含图像的标题和 link。
但在 laravel 中,我不知道在哪个文件夹中以及如何 return 将在移动应用程序上显示的完整图像 link。
数据保存在 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
但是当我转到此 link 时出现未找到错误:抱歉,找不到您要查找的页面。
echo asset('/storage/app/public/images/example.png');
这应该回应类似
的内容yourpage.com/storage/bla/bla/example.png