日期:2014-05-17 浏览次数:20398 次
$boundary = md5(time()); $postStr = ""; $postStr .="--".$boundary."\r\n"; $postStr .="Content-Disposition: form-data; name=\"uptxt[]\"; filename=\"index_1.html\"\r\n"; $postStr .="Content-Type: text/html\r\n\r\n"; $postStr .=$uploadFile."\r\n"; #这里是部分文件内容 $postStr .="--".$boundary."\r\n";
$boundary = md5(time()); $postStr = ""; $postStr .="--".$boundary."\r\n"; $postStr .="Content-Disposition: form-data; name=\"uptxt[]\"; filename=\"index_1.html\""; $postStr .="Content-Type: text~html"; $postStr .="123\r\n"; #这里是部分文件内容 $postStr .="--".$boundary."\r\n";
------解决方案--------------------
不是用curl吗?网上找了一段是这样的:
<?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'; ?>
------解决方案--------------------