G
G
gattsteroff2020-04-26 08:20:51
PHP
gattsteroff, 2020-04-26 08:20:51

Why can't the generated image (Captcha) be displayed?

A simple, notorious captcha was written for the Site , just to be. The problem is that on the local - it all works fine, but as soon as it is transferred to the hosting - it stops working. If you run this file manually, it will display an error referring to line 11, that is, to this one:

imageTtfText($im, 28, -25, 30, 25, $c, __DIR__."/fonts/18928.ttf", $rand);

Captcha code:
<?php
    session_start();
    $rand = mt_rand(1000000, 9999999);

    $_SESSION["rand"] = $rand;
 
    $im = imageCreateTrueColor(250,90,);
 
    $c = imageColorAllocate($im, 55, 55, 55);
 
    imageTtfText($im, 28, -25, 30, 25, $c, __DIR__."/fonts/18928.ttf", $rand);
 
    header("Content-type: image/png");
 
    imagePng($im);
 
    imageDestroy($im);
?>

How it looks on local:
5ea518c0dd67b899434278.png
And already in public access:
5ea518e0c438e429248429.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question