1 /**2 * Send POST request3 */4 functionDoPost2 ($url,$postdata) {5 //Initialize6 $curl=curl_init ();7 //Set Post submission8curl_setopt ($curl, Curlopt_post, 1);9 //set the crawled URLTencurl_setopt ($curl, Curlopt_url,$url); One //set the submitted data Acurl_setopt ($curl, Curlopt_postfields,$postdata); - //The information obtained is returned in the form of a file stream, rather than as a direct output. -curl_setopt ($curl, Curlopt_returntransfer, 1); the //set the header file information as the data stream output -curl_setopt ($curl, Curlopt_httpheader,Array(' Application/x-www-form-urlencoded;charset=utf-8 ')); - - $res= Curl_exec ($curl); + //Close URL Request -Curl_close ($curl); + A return $res; at}
1 /**2 * Upload images to CDN server3 * @param the absolute address of a picture of string File_path4 * @return String returns the picture address5 */6 functionUPLOAD_CDN ($file _path) {7 if(class_exists(' \curlfile ')) {//The PHP version is judged by feature detection .8 $file _path=New\curlfile (Realpath($file _path));//>=5.59}Else {Ten $file _path= ' @ '.$file _path;//<=5.5 One } A - $url= "Server Address"; - the $data=Array( -' Imgfile1 ' =$file _path, -' Phpsessid ' = ' ba4d1587aab023fd8cfa28fbe36c8235 ', -' Totalform ' = ' 1 ' + ); - + $result= DoPost2 ($url,$data); A at return $result; - -}
Uploading images to a CDN server