我想从我的服务器下载一张图片到 Android 应用程序。我有这个 PHP 脚本:
$jpg = file_get_contents("./images/12345.jpg");
echo $jpg;
如何下载此图像并将其显示在 ImageView 中?
最佳答案
你必须在 echo 前发送 header :
$filename= "./images/12345.jpg";
header("Content-disposition: inline; filename=\"$filename\"");
header('Content-transfer-encoding: binary');
header('Content-type: image/jpg');
或测试它:
$filename= "./images/12345.jpg";
header("Content-disposition: attachment; filename=\"$filename\"");
header('Content-transfer-encoding: binary');
header('Content-type: image/jpg')
;
希望对你有帮助...
关于php - 使用php将位图从服务器下载到android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13510551/