200分求助CURL设置HTTPHEADER上传文件问题!(补充提问)
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> $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"; <br><font color="#e78608">------解决方案--------------------</font><br>不是用<a style="color:#f60; text-decoration:underline;" title="curl" href="https://www.php.cn/zt/17285.html" target="_blank">curl</a>吗?网上找了一段是这样的:<br>
<?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';
?><br><font color="#e78608">------解决方案--------------------</font><br>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号