1PHP version >=5.5 file paths need to be processed2<?PHP3 $url= "http://127.0.0.1/PHPcode/upload_output.php";4 5 //1. Initialize6 $ch= Curl_init ($url);7 $path=Realpath("A.jpg");8 //php5.5 above requires an absolute address and uses Curlfile to create a file object9 $file=NewCurlfile ($path, "Image/jpeg", "Test_name");Ten $data=Array(' test_name ' =$file); One //2. Set options, including URL Acurl_setopt ($ch, Curlopt_returntransfer, 1);//The information obtained by CURL_EXEC () is returned as a file stream, - //rather than direct output - //Enable header file information to be output as data flow information the //Set post -curl_setopt ($ch, Curlopt_post, 1); - - //Add the post variable +curl_setopt ($ch, Curlopt_postfields,$data); - //3. Execute and get HTML document content + $output= Curl_exec ($ch); A at //4. Release the curl handle -Curl_close ($ch); - Echo $output; -?>
Curl Uploading files