PHP 显示图片。

$sourcePath = "图片路径";

$showImg = function($sourcePath) {
    $info = getimagesize($sourcePath);//获取图片信息
    $geshi = $info['mime'];//获取类型
    $im = file_get_contents($sourcePath); //获取图片的内容
    Http::header("Content-type: {$geshi}");//输出类型,直接取图片'mime'
    echo($im);
};

猜你喜欢

转载自blog.csdn.net/Stone_89/article/details/85280606
今日推荐