97久久国产亚洲精品超碰热,成人又色又爽的免费网站,色偷偷女人的天堂a,男女高潮喷水在线观看,国内精品一线二线三线区别在哪里

返回列表 發(fā)帖
查看: 5472|回復(fù): 3

解決https下IE上傳圖片不顯示問(wèn)題

83

主題

-6

回帖

329

積分

爐火純青

貢獻(xiàn)
2 點(diǎn)
金幣
241 個(gè)
樓主
發(fā)表于 2019-6-2 15:19:34 | 只看樓主 |倒序?yàn)g覽 |閱讀模式


版本 dx 3.3

估計(jì)3.4一樣有這個(gè)問(wèn)題,ie內(nèi)核的瀏覽器下在上傳后,縮略圖都是顯示xx。

這個(gè)問(wèn)題主要還是https下,對(duì)圖片輸出的時(shí)候 不能使用
  1. dheader('Content-Type: image');
復(fù)制代碼


必須要明確到j(luò)peg,png這里。

在forum_image.php文件里59行左右
需要改為
  1. dheader('Content-Type: image/jpeg');
復(fù)制代碼
當(dāng)然這個(gè)并不完美
  1. if($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
  2.                 if($nocache) {
  3.                         dheader('Content-Type: image/jpeg');
  4.                         @readfile($_G['setting']['attachdir'].$thumbfile);
復(fù)制代碼


這樣會(huì)讓png的圖片無(wú)法顯示出來(lái)。

可以增加一個(gè)函數(shù),來(lái)獲取mime類型。

  1. function get_image_extension($image){
  2.      $extension = pathinfo($filename,PATHINFO_EXTENSION);
  3.      if(in_array($extension,['jpg','jpeg','png','gif','bmp'])){
  4.       return  'image/'.$extension;
  5. }
  6.     return 'image';
  7. }
復(fù)制代碼
然后再去修改這個(gè)文件里輸出的頭部。
才可以徹底解決這個(gè)問(wèn)題。

php 5.3之后可以使用

  1. function get_image_extension($filename){
  2.         $finfo = finfo_open(FILEINFO_MIME_TYPE);
  3.         $rs = '';
  4.         if (!$finfo) {
  5.             return 'image';
  6.         }
  7.         $rs = finfo_file($finfo, $filename);
  8.         finfo_close($finfo);
  9.         return $rs;
  10. }
復(fù)制代碼

  1. <?php

  2. /**
  3. *      [Discuz!] (C)2001-2099 Comsenz Inc.
  4. *      This is NOT a freeware, use is subject to license terms
  5. *
  6. *      $Id: forum_image.php 32531 2013-02-06 10:15:19Z zhangguosheng $
  7. */

  8. if(!defined('IN_DISCUZ') || empty($_GET['aid']) || empty($_GET['size']) || empty($_GET['key'])) {
  9.         header('location: '.$_G['siteurl'].'static/image/common/none.gif');
  10.         exit;
  11. }

  12. $nocache = !empty($_GET['nocache']) ? 1 : 0;
  13. $daid = intval($_GET['aid']);
  14. $type = !empty($_GET['type']) ? $_GET['type'] : 'fixwr';
  15. list($w, $h) = explode('x', $_GET['size']);
  16. $dw = intval($w);
  17. $dh = intval($h);
  18. $thumbfile = 'image/'.helper_attach::makethumbpath($daid, $dw, $dh);$attachurl = helper_attach::attachpreurl();
  19. function get_image_extension($filename){
  20.         $finfo = finfo_open(FILEINFO_MIME_TYPE);
  21.         $rs = '';
  22.         if (!$finfo) {
  23.             return 'image';
  24.         }
  25.         $rs = finfo_file($finfo, $filename);
  26.         finfo_close($finfo);
  27.         return $rs;
  28. }

  29. if(!$nocache) {
  30.         if(file_exists($_G['setting']['attachdir'].$thumbfile)) {
  31.                 dheader('location: '.$attachurl.$thumbfile);
  32.         }
  33. }

  34. define('NOROBOT', TRUE);

  35. $id = !empty($_GET['atid']) ? $_GET['atid'] : $daid;
  36. if(dsign($id.'|'.$dw.'|'.$dh) != $_GET['key']) {
  37.         dheader('location: '.$_G['siteurl'].'static/image/common/none.gif');
  38. }

  39. if($attach = C::t('forum_attachment_n')->fetch('aid:'.$daid, $daid, array(1, -1))) {
  40.         if(!$dw && !$dh && $attach['tid'] != $id) {
  41.                dheader('location: '.$_G['siteurl'].'static/image/common/none.gif');
  42.         }
  43.         dheader('Expires: '.gmdate('D, d M Y H:i:s', TIMESTAMP + 3600).' GMT');
  44.         if($attach['remote']) {
  45.                 $filename = $_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment'];
  46.                 dheader('Content-Type: image');
  47.                 dheader('location: '.$_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment'].'?imageView2/1/w/'.$dw.'/h/'.$dh.'/format/jpg/interlace/0/q/80');
  48.                
  49.         } else {
  50.                 $filename = $_G['setting']['attachdir'].'forum/'.$attach['attachment'];
  51.         }
  52.         require_once libfile('class/image');
  53.         $img = new image;
  54.         if($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
  55.                 if($nocache) {
  56.                         $mine = get_image_extension($_G['setting']['attachdir'].$thumbfile);
  57.                         dheader('Content-Type: '.$mine);
  58.                         @readfile($_G['setting']['attachdir'].$thumbfile);
  59.                 //echo file_get_contents($_G['setting']['attachdir'].$thumbfile);
  60.                         @unlink($_G['setting']['attachdir'].$thumbfile);
  61.                 } else {
  62.                         dheader('location: '.$attachurl.$thumbfile);
  63.                 }
  64.         } else {
  65.                 dheader('Content-Type: image');
  66.                 @readfile($filename);
  67.         }
  68. }

  69. ?>
復(fù)制代碼


15

主題

1886

回帖

2187

積分

應(yīng)用開(kāi)發(fā)者

discuz 老兵

貢獻(xiàn)
12 點(diǎn)
金幣
198 個(gè)
QQ
沙發(fā)
發(fā)表于 2019-6-2 19:08:38 | 只看Ta
:lol感謝分享 干貨!!

1

主題

192

回帖

226

積分

爐火純青

貢獻(xiàn)
0 點(diǎn)
金幣
32 個(gè)
板凳
發(fā)表于 2019-6-16 15:39:53 | 只看Ta
感謝分享。。

0

主題

3

回帖

8

積分

初學(xué)乍練

貢獻(xiàn)
0 點(diǎn)
金幣
5 個(gè)
地板
發(fā)表于 2022-12-1 05:13:21 | 只看Ta
水平tall

本版積分規(guī)則

  • 關(guān)注公眾號(hào)
  • 有償服務(wù)微信
  • 有償服務(wù)QQ

手機(jī)版|小黑屋|Discuz! 官方交流社區(qū) ( 皖I(lǐng)CP備16010102號(hào) |皖公網(wǎng)安備34010302002376號(hào) )|網(wǎng)站地圖|star

GMT+8, 2025-10-16 17:19 , Processed in 0.057487 second(s), 10 queries , Redis On.

Powered by Discuz! X5.0 Licensed

© 2001-2025 Discuz! Team.

關(guān)燈 在本版發(fā)帖
有償服務(wù)QQ
有償服務(wù)微信
返回頂部
快速回復(fù) 返回頂部 返回列表