php函数显示内容类型和readfile的图像不起作用

时间:2017-11-30 16:05:59

标签: php html readfile

我有这段代码

switch ($pic_info['filetype'])
{
    case 'gif':
        $file_header = 'Content-Type: image/gif';
        break;
    case 'jpg':
        $file_header = 'Content-Type: image/jpeg';
        break;
    case 'png':
        $file_header = 'Content-Type: image/png';
        break;
    default:
        image_no_thumbnail('thumb_' . $pic_info['title_reg'] . '.' . $pic_info['filetype']);
        exit;
        break;
}

if(($album_config['thumbnail_cache'] == true) && file_exists($pic_info['thumbnail_s_fullpath']))
{
    header($file_header);
    header('Content-Length: ' . filesize($pic_info['thumbnail_s_fullpath']));
    header('Content-Disposition: filename=thumb_' . $pic_info['title_reg'] . '.' . $pic_info['filetype']);
    readfile($pic_info['thumbnail_s_fullpath']);
    exit;
}

但我有错误消息:无法显示图像,因为它包含错误。

使用文件类型png生成测试,并且thumbnail_s_fullpath是相对URL" ./ files / album / cache / 73 / 36e53725bb03b301b8521c755c036994.png" (但我尝试使用完整网址)。

我已经在没有结果的情况下重读了这个主题: php call a function from a img src

the image cannot be displayed because it contains errors

output an image in php

0 个答案:

没有答案