你这个是要上传图片到别的服务器吧
$imgurl = 'E:\test.jpg';// 本地图片地址
$api = 'https://sp0.baidu.com/6_R1fD_bAAd3otqbppnN2DJv/Pic/upload?pid=super&app=skin&l&logid=3813390493';
$file = realpath($imgurl);
$ch = curl_init();
if (class_exists('\CURLFile')) {// 这里用特性检测判断php版本
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
$post_data['file'] = new CURLFile($file);
} else {
if (defined('CURLOPT_SAFE_UPLOAD')) {
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
$post_data['file'] = '@' . $file;
}
}
curl_setopt($ch, CURLOPT_URL, $api);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
print_r($output);