php - 使用php将位图从服务器下载到android

标签 php android image download

我想从我的服务器下载一张图片到 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/

相关文章:

java - ListView 中 RadioGroups 中的其他按钮被选中

jquery - 在 Canvas 中上传的图像拖动,可触摸和可在 html5 中旋转

php - 如何将这些坐标转换为 Google map 可读的坐标?

android - 如何在 firebase 中获取与当前用户关联的帐户

php - 如何使用 Python 将 HTTP POST 值发送到 (PHP) 页面?

android - Chaquopy 没有初始化类

objective-c - 检测图像 iOS 中的黑色像素

android - GridView 内存不足错误

php - PHP 中的 iterator_to_array 函数是什么?

php - 发布当前评论时间