bucuo123 发表于 2013-2-6 10:15:19

解决https下IE上传图片不显示问题

解决https下IE上传图片不显示问题
解决https下IE上传图片不显示问题
版本 dx 3.3
估计3.4一样有这个问题,ie内核的浏览器下在上传后,缩略图都是显示xx。
这个问题主要还是https下,对图片输出的时候 不能使用
dheader('Content-Type: image');
复制代码
必须要明确到jpeg,png这里。
在forum_image.php文件里59行左右
需要改为
[ol,[*,dheader('Content-Type: image/jpeg');[/ol,复制代码
复制代码
当然这个并不完美
[ol,[*,if($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
[*,                if($nocache) {
[*,                        dheader('Content-Type: image/jpeg');
[*,                        @readfile($_G['setting',['attachdir',.$thumbfile);[/ol,复制代码
这样会让png的图片无法显示出来。
可以增加一个函数,来获取mime类型。
[ol,[*,function get_image_extension($image){
[*,   $extension = pathinfo($filename,PATHINFO_EXTENSION);
[*,   if(in_array($extension,['jpg','jpeg','png','gif','bmp',)){
[*,      return'image/'.$extension;
[*,}
[*,    return 'image';
[*,}[/ol,复制代码
然后再去修改这个文件里输出的头部。
才可以彻底解决这个问题。
php 5.3之后可以使用
[ol,[*,function get_image_extension($filename){
[*,      $finfo = finfo_open(FILEINFO_MIME_TYPE);
[*,      $rs = '';
[*,      if (!$finfo) {
[*,            return 'image';
[*,      }
[*,      $rs = finfo_file($finfo, $filename);
[*,      finfo_close($finfo);
[*,      return $rs;
[*,}[/ol,复制代码
[ol,[*,fetch('aid:'.$daid, $daid, array(1, -1))) {
[*,      if(!$dw && !$dh && $attach['tid', != $id) {
[*,               dheader('location: '.$_G['siteurl',.'static/image/common/none.gif');
[*,      }
[*,      dheader('Expires: '.gmdate('D, d M Y H:i:s', TIMESTAMP + 3600).' GMT');
[*,      if($attach['remote',) {
[*,                $filename = $_G['setting',['ftp',['attachurl',.'forum/'.$attach['attachment',;
[*,                dheader('Content-Type: image');
[*,                dheader('location: '.$_G['setting',['ftp',['attachurl',.'forum/'.$attach['attachment',.'?imageView2/1/w/'.$dw.'/h/'.$dh.'/format/jpg/interlace/0/q/80');
[*,               
[*,      } else {
[*,                $filename = $_G['setting',['attachdir',.'forum/'.$attach['attachment',;
[*,      }
[*,      require_once libfile('class/image');
[*,      $img = new image;
[*,      if($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
[*,                if($nocache) {
[*,                        $mine = get_image_extension($_G['setting',['attachdir',.$thumbfile);
[*,                        dheader('Content-Type: '.$mine);
[*,                        @readfile($_G['setting',['attachdir',.$thumbfile);
[*,                //echo file_get_contents($_G['setting',['attachdir',.$thumbfile);
[*,                        @unlink($_G['setting',['attachdir',.$thumbfile);
[*,                } else {
[*,                        dheader('location: '.$attachurl.$thumbfile);
[*,                }
[*,      } else {
[*,                dheader('Content-Type: image');
[*,                @readfile($filename);
[*,      }
[*,}
[*,
[*,?>[/ol,复制代码
页: [1]
查看完整版本: 解决https下IE上传图片不显示问题