imagettftext() - 找不到字体位置
我正在使用 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
This is line 17;
imagettftext($img, 25, 0, 0, 25, $text, "fonts/alger.ttf", $num);
我肯定已经上传了带有该字体的文件夹“fonts”,它位于 public_html 文件夹中。
有什么想法吗?
注意:我无权更改任何 PHP 配置,因为我使用的是共享托管帐户。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
imagettftext 文档说:
你尝试过这个吗?您可以使用
gd_info
来检查您正在使用哪个版本的 GD。The
imagettftext
documentation says:Did you try this? You can use
gd_info
to check which version of GD you are working with.解决了。事实证明,文件名是“alger.TTF”,文件扩展名大写,在我的代码中,我用小写扩展名引用它。由于某种原因,这在 PHP 5.3.8 中仍然有效,但在 PHP 5.2.17 中无效,我希望这可以帮助遇到此问题的其他人
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