function load_image() {
header('ETag: 8ba645e803f8dc1020b1a74b5ec03fba');
header('Last-Modified: Tue, 21 Jul 2015 10:36:31 GMT');
header('Content-Type: image/jpeg');
header('Content-Length: 41374' );
echo readfile("images/France/paris.jpg");
exit;
}
我有这个codeigniter函数它应该读取图像并将其加载到浏览器中但是我有错误
/France/paris.jpg” cannot be displayed because it contains errors.
在header()之前不能输出任何内容。只需用<?php
开始文档,后面跟着显示图像的代码。跳过html标签。甚至在header()之前都不要写空行。
ob_clean -清除(擦除)输出缓冲区,有助于操作图像和PHP。我应该在ob_start
我已经检查了图像路径是否正确设置或是否只传递空值。
如果没有找到图像,则在Firefox中给出此错误。在IE中,它显示样方框。Chrome中没有显示错误信息
因此,检查图像是否正确传递或传递空值。
在我的代码中,我这样检查
if(!empty("Passing image here path"))
{
compress image here
}