在 PHP 中输出图像 [英] Output an Image in PHP
本文介绍了在 PHP 中输出图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图像 $file
(例如 ../image.jpg
)
I have an image $file
( eg ../image.jpg
)
有一个 mime 类型 $type
which has a mime type $type
如何将其输出到浏览器?
How can I output it to the browser?
推荐答案
$file = '../image.jpg';
$type = 'image/jpeg';
header('Content-Type:'.$type);
header('Content-Length: ' . filesize($file));
readfile($file);
这篇关于在 PHP 中输出图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文