开发者社区 问答 正文

sae 使用imagettftext总是提示 imagettftext() [function.imagettftext],求助。

本地测试没有问题,上传到sae上的时候就会这样报错
代码:screenshot
错误为:
screenshot
stackoverflow上有篇解决这个的提问:http://stackoverflow.com/questions/10366679/warning-imagettftext-function-imagettftext-could-not-find-open-font-in-ho 按照他的方法,前面加/没用,又说Linux下要使用绝对路径,sae上怎么使用绝对路径?

展开
收起
落地花开啦 2016-06-14 10:55:45 2175 分享 版权
1 条回答
写回答
取消 提交回答
  • 喜欢技术,喜欢努力的人
    <?php
    echo dirname(__FILE__);

    看看输出。你可以得到绝对路径。
    选用字体文件,的确是需要使用绝对路径。
    一般都会有一个类似common.inc.php这样的文件,作用就是公共加载文件,功能就是连接数据库、定义网站在服务器的根目录的绝对路径等。

    // /common.inc.php
    <?php
    
    define('__PATH__',dirname(__FILE__));
    
    php // /api/weather.php require_once '../common.inc.php';
    
    $fontfile = PATH.'/font.ttf'; $gd = imagecreatefromgd(); imagettftext ( $gd , $size , $angle , $x , $y , $color , $fontfile , $text )
    
    ?> 
    2019-07-17 19:36:59
    赞同 展开评论
问答分类:
问答标签:
问答地址: