iT邦幫忙

0

captcha.php顯示不出圖檔

我剛安裝了xampp,把以前的檔案放進去, 想在本機進後台login, 但captcha出不了圖.
https://ithelp.ithome.com.tw/upload/images/20200831/20130036f4ekrdzoxM.jpg
我查看eccess.log是看到這兩行:
::1 - - [31/Aug/2020:10:23:01 +0800] "GET /hkcas1/hkadmin/login.php HTTP/1.1" 200 5620 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
::1 - - [31/Aug/2020:10:23:01 +0800] "GET /hkcas1/hkadmin/captcha.php HTTP/1.1" 200 329 "http://localhost/hkcas1/hkadmin/login.php" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
查看error.log看到這個:
[Mon Aug 31 10:27:56.694017 2020] [php7:warn] [pid 9460:tid 1852] [client ::1:60658] PHP Warning: imagettftext(): Could not find/open font in C:\xampp\htdocs\hkcas1\hkadmin\captcha.php on line 45, referer: http://localhost/hkcas1/hkadmin/login.php
我captcha.php的內容是這樣:
https://ithelp.ithome.com.tw/upload/images/20200831/20130036vYpNpaetnY.jpg
我查看phpinfo,好像沒有什麼沒安裝好:
https://ithelp.ithome.com.tw/upload/images/20200831/20130036mrG5y74C7r.jpg

請問大家前輩,我哪裡沒做好呢? 還是其他問題?

我的fonts資料夾檔都在:
https://ithelp.ithome.com.tw/upload/images/20200831/20130036p0WO8C7OOw.jpg

也試過直接放在跟captcha.php同層一樣是error.log那句出現
我本機看不到, 但正式機就沒這狀況

新手不能直接回應下面兩位前輩的提議, 我就在此回應, 我也試過改第43行的路徑,"hkadmin/fonts/vintage.ttf"或是"hkcas1/hkadmin/fonts/vintage.ttf"等的但不成功, 而error.log也會顯示這句:
[Mon Aug 31 14:25:19.090221 2020] [php7:warn] [pid 9460:tid 1868] [client ::1:50886] PHP Warning: imagettftext(): Invalid font filename in C:\xampp\htdocs\hkcas1\hkadmin\captcha.php on line 45, referer: http://localhost/hkcas1/hkadmin/login.php

請問如果正式機沒有出現這狀況, 是否我本機xampp的有系統問題?
我之前有裝過xampp的7.1.7版沒有出現現在的問題,現在因為換新牒,所以重裝了比較新的版本就卡在這個captcha圖不出現的問題

2020/09/04補充
各位前輩,謝謝你們的建議,我後來解決了上面的問題就是我uninstall了這個新下載的版本,然後再裝回我之前用的7.1.7版本就沒事了,圖檔都正常出現。所以我強烈認為我安裝的比較新的版本的是有路徑相衝問題,但我能力有限找不出原因,所以就裝回舊版。

以下是我發生問題的下載處版本PHP7.3.6-2
https://123.briian.com/forum.php?mod=viewthread&tid=2355
https://ithelp.ithome.com.tw/upload/images/20200904/20130036IXip60UQ5B.jpg
就是下載了後都顯示不了captcha圖檔
如果前輩想嘗試是否出現同樣問題, 可以試看看, 或者前輩們可以找出原因。
在此謝謝大家的回覆及意見。

fillano iT邦超人 1 級 ‧ 2020-08-31 16:59:34 檢舉
$_SERVER["DOCUMENT_ROOT"]."/hkcas1/hkadmin/fonts/vintage.ttf" 試試看
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
rogeryao
iT邦超人 8 級 ‧ 2020-08-31 11:08:47

檢查你的電腦中是否有第 43 行內的 3 個 ttf 檔 ,或是路徑不對

0

PHP Warning: imagettftext(): Could not find/open font in C:\xampp\htdocs\hkcas1\hkadmin\captcha.php on line 45, referer:

這段錯誤已經告訴你字型檔無法打開。
你要先確定字型檔的正確性。
看你用相對路徑,可以試著先用絕對路徑試試。

我要發表回答

立即登入回答