Home > Backend Development > PHP Tutorial > PHP怎么保存验证码图片到本地

PHP怎么保存验证码图片到本地

WBOY
Release: 2016-06-13 10:18:57
Original
1061 people have browsed it

PHP如何保存验证码图片到本地?
最近在做一些自动化的东西,
其中涉及到验证码识别,
遇到的验证码图片是类似于
PHP怎么保存验证码图片到本地
这样的,
用PHP的 file_get_contents或者curl,
去按照平时保存jpg、bmp这种文件的方法,
遇到保存不了的问题,

各位高手支个招

------解决方案--------------------

PHP code
<?php function GrabImage($url,$filename="") { if($url==""):return false;endif; if($filename=="") { $ext=strrchr($url,"."); if($ext!=".gif" && $ext!=".jpg"):return false;endif; $filename=date("dMYHis").$ext; } ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); $size = strlen($img); [email&#160;protected]($filename, "a"); fwrite($fp2,$img); fclose($fp2); return $filename; }<div class="clear">
                 
              
              
        
            
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template