PHP gets Remote authentication code to local PHP function code

Source: Internet
Author: User

PHP obtains the CAPTCHA code picture to the local, supports the PNG, GIF, JPG three format authentication code. In the implementation, PHP judge picture format is the use of PHP built-in Exif_imagetype function, is really more convenient, learn PHP may wish to refer to the following code:

View SOURCEPRINT?01

02header ("Content-type:image/png");

03set_time_limit (0);/Set timeout time

04$url = $_get[' url '];

05$url = "Http://vcer.baidu.com/verify";

06if (Empty ($url)) {

echo "No pictures";

Die;

09}

10$imginfo = getimagesize ($url);

11$type = Exif_imagetype ($url);

12$IMGW = $imginfo [0];

13$IMGH = $imginfo [1];

14$BG = Imagecreatetruecolor ($IMGW, $IMGH);

15if ($type ==imagetype_gif) {

$image = Imagecreatefromgif ($url);

17}elseif ($type ==imagetype_jpeg) {

$image = Imagecreatefromjpeg ($url);

19}elseif ($type ==imagetype_png) {

$image = Imagecreatefrompng ($url);

21}

22imagecolorallocate ($image, 255,255,255);

23imagecopy ($BG, $image, 0,0, 0,0, $IMGW, $IMGH);

24imagedestroy ($image);

25ImagePng ($BG);

26?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.