imagettftext()-找不到字体位置 [英] imagettftext() - Cannot find font location
问题描述
我正在使用imagettftext()函数创建自定义的验证码脚本.
我已经在运行PHP(版本5.3.8)的PC上成功运行并测试了代码,但是当我上传到运行PHP(版本5.2.17)的共享托管帐户时,出现以下错误
Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/pheelco/public_html/captcha.php on line 17
这是第17行;
imagettftext($img, 25, 0, 0, 25, $text, "fonts/alger.ttf", $num);
我肯定有使用该字体上传的文件夹"fonts",它在public_html文件夹中.
有什么想法吗?
注意:由于我使用的是共享托管帐户,因此我无权更改任何PHP配置.
已解决.原来文件名是"alger.TTF",带有大写的文件扩展名,在我的代码中,我使用的是小写扩展名.出于某种原因,它在PHP 5.3.8中仍然有效,但在PHP 5.2.17中却不起作用.
I am using the imagettftext() function to create a custom captcha script.
I have ran and tested the code successfully on my PC, running PHP (Version 5.3.8) but when I upload to my shared hosting account running PHP (Version 5.2.17) it comes up with the following error
Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/pheelco/public_html/captcha.php on line 17
This is line 17;
imagettftext($img, 25, 0, 0, 25, $text, "fonts/alger.ttf", $num);
I definitely have the folder "fonts" uploaded with that font, its in the public_html folder.
Any ideas?
Note: I don't have access to change any PHP configurations, as I'm using a shared hosting account.
Solved. It turned out the file name was "alger.TTF" with a capitalised file extension and in my code I was referring to it with a lower-case extension. For some reason this still worked in PHP 5.3.8 but not in PHP 5.2.17 I hope this helps anybody else that comes across this issue
这篇关于imagettftext()-找不到字体位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!