二维码转存为图片

Posted on 2018-05-09 17:52  pai片儿的  阅读(178)  评论(0编辑  收藏  举报
public function index(){
       $url = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEA8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLn';
            $file =  "public/uploads/1.jpg";
            $ch = curl_init($url);
            $fp = fopen($file, 'wb');
            curl_setopt($ch, CURLOPT_FILE, $fp);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_exec($ch);
            // curl_close($ch);
            fclose($fp);$fp = fopen($file, 'wb');
            curl_setopt($ch, CURLOPT_FILE, $fp);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_exec($ch);
            curl_close($ch);
            fclose($fp);
    }