File does not exit or not found

I implement captcha in the project. I am using frameworkignign framework. In the captcha_helper.php file, the code

$use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE;

returns false. Because it file_exists($font_path)returns false . I am walking through

$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);

Now that I echo $font_pathand copy and paste the same URL in the browser, the font file will be requested as the download path. So why file_exists($font_path)returns false . I tried my best I could not figure it out. Please help me and forgive my stupid mistakes, if any.

+4
source share
2 answers

Try:

$font_path = realpath($image_path . 'font/impact.ttf');

, base_url() URL-, , (, /home/yoursite/public_html/captcha/font/impact.ttf)

+2

PHP, file_exists : , URL-. HTTP-. , file_exists('/captcha/font/impact.ttf') true!

+2

Source: https://habr.com/ru/post/1610630/


All Articles