1

我想将图像从我的服务器下载到 Android 应用程序。我有这个 PHP 脚本:

$jpg  = file_get_contents("./images/12345.jpg");

echo $jpg;

如何下载此图像并将其显示在 ImageView 中?

4

1 回答 1

2

您必须在 echo 之前发送标头:

    $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')

;

我希望能帮助你...

于 2012-11-22T10:27:24.677 回答