我想通过PHP脚本显示一个图像,以便你在html中有一个普通的img但是有一个php脚本的源代码.然后,此脚本将打开现有的png或jpg图像,并通过它显示该图像.
我一直在尝试这段代码而没有运气.
$img = imagecreatefrompng("logo.png"); header("Content-type: image/png"); imagepng($img); imagedestroy($img);
图像输出没有错误.
提前致谢.
Jac*_*iuk 12
header("Content-type: image/png");
readfile("$file");
exit;
Run Code Online (Sandbox Code Playgroud)
最好添加一些标题,例如:
header('Expires: 0');
header('Content-Length: ' . filesize($file));
Run Code Online (Sandbox Code Playgroud)
请看这里的讨论:http: //php.net/manual/en/function.readfile.php