java - 如何通过PHP显示存储在C:/xampp/htdocs/uploads文件夹中的图像作为android中的中间件
问题描述
我从getphotos.php
. 现在我想使用 Picasso 在 Android 中显示它,但它没有显示任何内容。我在 android 应用程序中成功获取了图像路径,但没有显示图像(路径类似于C:/xampp/htdocs/LBS/uploads/San-Coll.png
)。
毕加索版本是com.squareup.picasso:picasso:2.5.1
安卓代码:
private void showPlacements() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(APIUrl.BASE_URL)
.addConverterFactory(GsonConverterFactory.create()) //Here we are using the GsonConverterFactory to directly convert json data to object
.build();
APIService api = retrofit.create(APIService.class);
Call<List<Placement>> call = api.showPlacement();
call.enqueue(new Callback<List<Placement>>() {
@Override
public void onResponse(Call<List<Placement>> call, Response<List<Placement>> response) {
placementList = response.body();
layoutManager = new LinearLayoutManager(PlacementActivity.this);
recyclerView.setLayoutManager(layoutManager);
PlacementAdapter recyclerViewAdapter = new PlacementAdapter(getApplicationContext(), placementList);
recyclerView.setAdapter(recyclerViewAdapter);
}
@Override
public void onFailure(Call<List<Placement>> call, Throwable t) {
}
});
}
PHP代码:
<?php
require 'dbconnect.php';
// print_r($table);die();
$sql="SELECT image_path from photos ";
$result = $con->query($sql);
$rows = array();
while($row = $result->fetch_assoc())
{
$rows[] =$row;
}
print json_encode($rows);
?>
解决方案
我不认为毕加索可以加载本地图像;这意味着不要从互联网上下载它们。像https://example.com/imageurl 更新:您可以:Picasso 从文件系统加载图像,但您的服务器不是本地文件系统。
推荐阅读
- c# - PHP的random_bytes的C#等效函数
- flask - drop_all() 中的 SQLAlchemy DDL 语句错误仅在 AWS 上发生
- c# - 如何在同一个函数中重新调整两个对象?
- asp.net - ASP.NET 中的 Xero 授权取消
- cordova - phoneRTC 离子的补充
- postgresql - 带有双引号的 PG_BULKLOAD 空值到时间戳字段
- amazon-web-services - 多区域应用程序的 AWS 延迟改进
- php - PHP - RethinkDB 给我“加载失败:”错误
- html - 带有 Astra 主题的子菜单
- python - 将数据框列从对象转换为 timedelta 并求和