php 从第三方服务器download图片到本地

public function downPdfFromSSQ($contract_id,$url){
   // $url = 'https://openapi.bestsign.info/openapi/v2/storage/contract/download/?sign=OsfjtxLOQ2%2FMplZLGg6hssF
    //%2BDkWtAXDpIREX%2BjNc36SeG8dCPGESGZ00BOGgOz%2FB7GQKO3YPW5IFrfSVFJ5wlBTAW0yz0J0MBKodrDwwTuRmUP1%2BSGOwKgY6jf0oyVASO6%2FYKhMl76G1OKBLTYwwIbGfnvcRnAZBqGmQe0In6KI%3D&developerId=1978813375945114153&rtick=15369196509036&signType=rsa&contractId=153691961701000001';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_HEADER,0);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_TIMEOUT,500);
    if(!file_exists('contracts/'.date('Ym'))){
       @mkdir('contracts/'.date('Ym'),0777,true);
    }
    $outfile = fopen('contracts/'.date('Ym').'/'.$contract_id.'.pdf',"wb+x");  //保存到本地文件的文件名
    curl_setopt($ch,CURLOPT_FILE,$outfile);
    $rtn = curl_exec($ch);
    fclose($outfile);
   if(!curl_errno($ch)){
        echo "RETURN: ".over;
    }else{
        echo 'Curl:error: '.curl_errno($ch);
    }
    curl_close($ch);
}
上一篇:阿里云容器宣布开放支持Kubernetes托管服务


下一篇:Photoshop调出外景婚纱照怀旧复古效果图