【问题标题】:header("Content-Type: image/jpeg") not working标头(“内容类型:图像/JPEG”)不工作
【发布时间】:2016-06-19 06:09:58
【问题描述】:

阅读了所有类似的问题后,没有任何情况像我一样。 切完所有废话后,我的代码是:

<?php
$file = 'Images\Bird1.jpg';
header('Content-Type: image/jpeg');
imagejpeg($file);
?>

但它显示一个空白页。路径\文件确实存在,我用如下代码检查了它:

if (file_exists($file))

文件类型确实是 image/jpeg,我还检查了我的代码的更广泛版本。请帮忙?

【问题讨论】:

    标签: php


    【解决方案1】:
    imagejpeg($file);
    

    此函数需要资源,而不是文件名。你正在寻找

    readfile($file);
    

    http://php.net/manual/en/function.readfile.php

    【讨论】:

      猜你喜欢
      • 2013-08-21
      • 1970-01-01
      • 2011-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-22
      相关资源
      最近更新 更多