index.php:

<?php
$post = array(
“pic1″=>”@”.realpath(‘tmp.txt’)//这里是要上传的文件,key与后台处理文件对应
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “http://sand.6te.net/example/php/ebaycurl/upload.php”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch,CURLOPT_USERAGENT,”Mozilla/4.0″);
 
$a=curl_exec($ch);
//$cinfo=curl_getinfo($ch);
//print $a;
   
curl_close($ch);
?>

upload.php:

if(move_uploaded_file($_FILES["pic1"]["tmp_name"], “2.txt”)){
echo ‘successfull’;
}

http://sand.6te.net/example/php/curlupload/index.php