转http://www.justwinit.cn/post/1771/
<?php
function upload_curl_pic()
{
$url = 'http://localhost//5-5-5//uploadfile.php'; //target url
$file = 'c:/21.jpg'; //要上传的文件
$fields['f'] = '@'.$file;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields );
curl_exec( $ch );
if ($error = curl_error($ch) ) {
die($error);
}
curl_close($ch);
}
upload_curl_pic();//可以扩展把图片地址传到函数中
?>