htmlの中にphpを使って同一サーバーの中に保存してある画像(拡張子は何でも良い)を表示したい。以下に様にしてみましたが分かりませんでした。
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta charset='utf-8'> </head> <body> <?php header('Content-Type: image/png'); readfile('test.png'); ?> <?php $lines = file('http://アドレス/test.jpeg'); ?> <?php $img_path = 'http://アドレス/images/test.png' ; $img = file_get_contents($img_path) ; header('Content-type: image/gif') ; echo $img ; ?> <?php $img = imagecreatetruecolor(100, 100) ; imagefill($img, 0, 0, 0xffffff) ; imagefilledrectangle($img, 30, 30, 100, 100, 0xff0000) ; header('Content-type: image/png') ; imagepng($img) ; ?> <?php header('Content-type: image/jpeg'); readfile('test.jpeg'); ?> <?php $image_path = 'test.png'; if (file_exists($image_path)) { header('Content-Type: アドレス?/test.png'); readfile($image_path); } ?> </body> </html>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。