load image from php directly into Glide

 ̄綄美尐妖づ 提交于 2019-12-12 09:27:44

问题


I have images as byte [] and I will load it directly into Glide some thing like this :

the Glide in recyclerView (Adapter):

Glide.with(ctx)
    .load("http://192.168.1.8/connect/getimage.php")
    .into(holder.img);

The script PHP ==> getimage.php

$sql = "select img from table where id=1032 ";


$stmt = sqlsrv_prepare($this - > connection, $sql);
$result = sqlsrv_execute($stmt);

$information = array();
while ($data = sqlsrv_fetch_array($stmt)) {
    $img = base64_encode($data['img']);
}

echo $img;

I would get It directly without Json to put it into Glide .


回答1:


replace this ligne

$img=base64_encode($data['img']);

by :

$img=$data['img'];

and it should work




回答2:


You shouldn't send image as base64 string. Just send it as ordinary file.



来源:https://stackoverflow.com/questions/42876455/load-image-from-php-directly-into-glide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!