PHP CURL 模拟POST请求上传文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mybluesky1983/article/details/79599713
$ch = curl_init();
 $post_data = array(
                'a'=>'Post',
		'c'=>'Api_Review',
                'file' => '@/tmp/5aaba5364618a.png'
            );
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);  
curl_setopt($ch,CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
curl_setopt($ch, CURLOPT_URL, '目标url');
$info= curl_exec($ch);
curl_close($ch);
   
print_r($info);

接收端 直接使用$_File 即可接收

猜你喜欢

转载自blog.csdn.net/mybluesky1983/article/details/79599713