Home > Backend Development > PHP Tutorial > Simulate fodder to upload QR code images and obtain recognition results

Simulate fodder to upload QR code images and obtain recognition results

WBOY
Release: 2023-03-02 14:16:01
Original
3422 people have browsed it

Now I want to simulate http://cli.im/deqr

Simulate fodder to upload QR code images and obtain recognition results
Upload the QR code recognition picture and observe with F12

Simulate fodder to upload QR code images and obtain recognition results
is to upload the picture post to http://upload.api.cli.im/uplo...,

Simulate fodder to upload QR code images and obtain recognition results
Then return an image address, and then post the image address to http://cli.in/apis/up/deqrimg

Simulate fodder to upload QR code images and obtain recognition results

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>
Copy after login
Copy after login

The $res returned by the above code will always be null. Normally, it should return an image address belonging to the fodder

Reply content:

Now I want to simulate http://cli.im/deqr

Simulate fodder to upload QR code images and obtain recognition results
Upload the QR code recognition picture and observe with F12

Simulate fodder to upload QR code images and obtain recognition results
is to upload the picture post to http://upload.api.cli.im/uplo...,

Simulate fodder to upload QR code images and obtain recognition results
Then return an image address, and then post the image address to http://cli.in/apis/up/deqrimg

Simulate fodder to upload QR code images and obtain recognition results

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>
Copy after login
Copy after login

The $res returned by the above code will always be null. Normally, it should return an image address belonging to the fodder

Related labels:
php
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