Uploading images to a CDN server

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.