我正在项目中实现验证码功能。我使用的是CodeIgniter框架。在captcha_helper.php文件中,代码如下:
$use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE;
返回了 false。因为 file_exists($font_path)
返回了 false。
我传递的参数是
$img_path = '../../captcha/';
$img_url = base_url() . 'captcha/';
$font_path = base_url(). 'captcha/font/impact.ttf';
$captch = array(
'word' => '',
'img_path' => $img_path,
'img_url' => $img_url,
'font_path' => $font_path,
'img_width' => '200',
'img_height' => '50',
'expiration' => '300'
);
$cap = create_captcha($captch);
现在,当我打印出
$font_path
并将相同的网址复制粘贴到浏览器中时,字体文件会提示下载,这意味着路径是正确的。那么,为什么file_exists($font_path)
返回false呢?我尽力了也想不明白。请帮帮我,如果有任何错误,请原谅我愚蠢的错误。