简体   繁体   中英

php generated images not showing in webview

I have an android app with a webview. Within the webview i have some php generated images (GDLIB)

<!-- Show a php generated image from GDLIB -->
<img src='graphs/graph.php'>

<?
// Graph.php
$src = imagecreatefrompng('mapStatus.png');
$dstC = imagecreatefromgif('pointClosed.gif');
$text_color=ImageColorAllocate($src,255,255,255);
imagecopymerge($src,$dstC,22,15,0,0,4,4,95);
header('Content-type: image/png');
imagepng($src);
imagedestroy($src);
?>

For some reason these images, are not being shown within the webview, while they work fine in a regular browser window. Replacing the path with a non-php generated image works fine.

Is there some workaround, so that I may be able to show php generated images in webview ?

EDIT: Webview shows a broken image like this:

Webview破碎的图像

instead of the actual picture that should look like this:

实际图片

Thank you

Try:

  • Double-checking your relative URL.
  • Specifying headers.

    header('Content-Type: image/png');

With that above your image output, your browser won't have to assume the content type, which it may be doing.

Check your console for 40X/500 errors and "expected type image/png but received text/html" or similar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM