imagecreatefromjpeg():gd-jpeg:JPEG库报告不可恢复的错误

时间:2017-12-27 10:33:32

标签: php

我正在创建验证码图像,但显示错误。代码有什么问题请帮助。

session_start();
    $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;
   //Generating CAPTCHA

    $save_url = base_path().'\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/png');
    imagepng($image,$save_url);

0 个答案:

没有答案