Cpatcha图像创建无法正常工作

时间:2017-12-27 06:37:52

标签: php

我正在尝试创建验证码图像但是每次都不知道原因是什么。这是我的代码。

    session_start();

    //Initializing PHP variable with string
    $captchanumber = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz';

    //Getting first 6 word after shuffle
    $captchanumber = substr(str_shuffle($captchanumber), 0, 6);

    //Initializing session variable with above generated sub-string
    $_SESSION["code"] = $captchanumber;
   // dd($_SESSION["code"]);
//dd(base_path().'\resources\assets\dist\images\bj.jpg');
    //Generating CAPTCHA

    $save_url = base_path().'\resources\assets\dist\images\bj.jpg'; // (URL('resources/assets/dist/images/bj.jpg'));
    $image = @imagecreatefromjpeg(base_path().'\resources\assets\dist\images\bj.jpg');

    $foreground = @imagecolorallocate($image, 175, 199, 200); //font color
    @imagestring($image, 5, 45, 8, $captchanumber, $foreground);
    header('Content-type: image/jpg');
    @imagepng($image,$save_url);

0 个答案:

没有答案