curl模拟文件post提交

 1 

curl模拟文件post提交
$filePath='d:/www/zjTest/txtFile'; 2 //$filepath = file_get_contents($filePath); 3 $fileName='txtFile'; 4 $data=array('txtFile'=>'@'.$filePath); 5 $url = 'url'; 6 $testurl = curl_init($url); 7 curl_setopt ($testurl, CURLOPT_POST, 1); 8 curl_setopt ($testurl, CURLOPT_POSTFIELDS,$data); 9 curl_setopt($testurl, CURLOPT_FOLLOWLOCATION ,1); 10 curl_setopt($testurl, CURLOPT_HEADER ,0); 11 curl_setopt($testurl, CURLOPT_RETURNTRANSFER ,1); 12 $result = curl_exec ($testurl); 13 $info = curl_getinfo($testurl); 14 echo $curl_errno = curl_errno($testurl); 15 echo '------------<br/>'; 16 echo $curl_error = curl_error($testurl); 17 18 echo '<pre>'; 19 print_r($result); 20 echo '</pre>'; 21 curl_close ($testurl);

 

posted @ 2013-03-01 14:09  尹少爷  阅读(2912)  评论(0编辑  收藏  举报