Posted By

lzyy on 04/13/09


Tagged

curl


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

hamiltonmascioli
dinkan


curl上传文件并获得跳转的内容


 / Published in: PHP
 

  1. <?php
  2. $url = 'http://www.myheritage.cn/FP/Company/tryFaceRecognition.php';//target url
  3.  
  4. $fields['file'] = '@'.'C:\Users\lzyy\Desktop\3431821560_5e18c02221.jpg';
  5. $fields['lang'] = 'ZH';
  6. $fields['morph'] = '1';
  7. $fields['popup'] = 'PJSLVMMT';
  8. $fields['loadMethod'] = 'myFiles';
  9.  
  10. $ch = curl_init();
  11.  
  12. curl_setopt($ch, CURLOPT_URL, $url );
  13. curl_setopt($ch, CURLOPT_POST, 1 );
  14. curl_setopt($ch, CURLOPT_POSTFIELDS, $fields );
  15. //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  16. curl_setopt ($ch, CURLOPT_REFERER, "http://www.myheritage.cn/");
  17. curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);//get redirect content
  18.  
  19. curl_exec( $ch );
  20. //$rs = curl_exec($ch);
  21.  
  22. if ($error = curl_error($ch) ) {
  23. die($error);
  24. }
  25. curl_close($ch);
  26. //print_r(htmlspecialchars($rs));
  27. echo 'ok';
  28. ?>

Report this snippet  

You need to login to post a comment.