Return to Snippet

Revision: 13173
at April 13, 2009 12:31 by lzyy


Updated Code
<?php
$url  = 'http://www.myheritage.cn/FP/Company/tryFaceRecognition.php';//target url

$fields['file'] = '@'.'C:\Users\lzyy\Desktop\3431821560_5e18c02221.jpg';
$fields['lang'] = 'ZH';
$fields['morph'] = '1';
$fields['popup'] = 'PJSLVMMT';
$fields['loadMethod'] = 'myFiles';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields );
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_REFERER, "http://www.myheritage.cn/");
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);//get redirect content

curl_exec( $ch );
//$rs = curl_exec($ch);

if ($error = curl_error($ch) ) {
          die($error);
}
curl_close($ch);
//print_r(htmlspecialchars($rs));
echo 'ok';
?>

Revision: 13172
at April 13, 2009 12:18 by lzyy


Initial Code
<?php
$url  = 'http://www.myheritage.cn/FP/Company/tryFaceRecognition.php';//target url

$fields['file'] = '@'.'C:\Users\lzyy\Desktop\3431821560_5e18c02221.jpg';
$fields['lang'] = 'ZH';
$fields['morph'] = '1';
$fields['popup'] = 'PJSLVMMT';
$fields['loadMethod'] = 'myFiles';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields );
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//获取返回值
curl_setopt ($ch, CURLOPT_REFERER, "http://www.myheritage.cn/");

curl_exec( $ch );
//$rs = curl_exec($ch);

if ($error = curl_error($ch) ) {
          die($error);
}
curl_close($ch);
//print_r(htmlspecialchars($rs));
echo 'ok';
?>

Initial URL

                                

Initial Description

                                

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

Initial Tags
curl

Initial Language
PHP