Home >Backend Development >PHP Tutorial >Simulate fodder to upload QR code images and obtain recognition results
Now I want to simulate http://cli.im/deqr
Upload the QR code recognition picture and observe with F12
is to upload the picture post to http://upload.api.cli.im/uplo...,
Then return an image address, and then post the image address to http://cli.in/apis/up/deqrimg
Then recognize the QR code.
I use PHP’s curl post to upload images, but it always displays null. Did I miss any parameters?
<code>public function index(){ $url='http://upload.api.cli.im/upload.php?kid=cliim'; $r_file='/test.jpg'; $res=$this->upload_file($url,$r_file); var_dump($res); } private function upload_file($url,$r_file) { $file = array("fax_file"=>'@'.$r_file,'type'=>'image/jpeg');//文件路径,前面要加@,表明是文件上传. $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,$url); curl_setopt($curl,CURLOPT_POST,1); curl_setopt($curl,CURLOPT_POSTFIELDS,$file); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, 0); $result = curl_exec($curl); //$result 获取页面信息 curl_close($curl); echo $result ; //输出 页面结果 }</code>
The $res returned by the above code will always be null. Normally, it should return an image address belonging to the fodder
Now I want to simulate http://cli.im/deqr
Upload the QR code recognition picture and observe with F12
is to upload the picture post to http://upload.api.cli.im/uplo...,
Then return an image address, and then post the image address to http://cli.in/apis/up/deqrimg
Then recognize the QR code.
I use PHP’s curl post to upload images, but it always displays null. Did I miss any parameters?
<code>public function index(){ $url='http://upload.api.cli.im/upload.php?kid=cliim'; $r_file='/test.jpg'; $res=$this->upload_file($url,$r_file); var_dump($res); } private function upload_file($url,$r_file) { $file = array("fax_file"=>'@'.$r_file,'type'=>'image/jpeg');//文件路径,前面要加@,表明是文件上传. $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,$url); curl_setopt($curl,CURLOPT_POST,1); curl_setopt($curl,CURLOPT_POSTFIELDS,$file); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, 0); $result = curl_exec($curl); //$result 获取页面信息 curl_close($curl); echo $result ; //输出 页面结果 }</code>
The $res returned by the above code will always be null. Normally, it should return an image address belonging to the fodder