PHP CURL 은 아 날로 그 로그 인 을 실현 하고 파일 작업 예 시 를 업로드 합 니 다.
3968 단어 PHPCURL아 날로 그 로그 인파일 업로드
<?php
header('content-type:text/html;charset=gb2312');
// ,
// php5.3 @, new CURLfile()
// header , 。 , 。
function curl_form($post_data,$sumbit_url,$http_url,$cookie_file){
$headers = array();
$headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
$headers[] = 'Cache-Control: max-age=0';
$headers[] = 'Accept-Encoding: gzip, deflate';
$headers[] = 'Origin: http://my.***.com';
$headers[] = 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3';
$headers[] = 'Upgrade-Insecure-Requests: 1';
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0';
$headers[] = 'Connection: keep-alive';
// $headers[] = 'Cookie: ASPSESSIONIDCCTCTQQC=KBGLPDKBIKDIDCBGFOKNMKOE';
//
$ch = curl_init();
//
curl_setopt($ch, CURLOPT_URL, $sumbit_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// ,0 ,1
curl_setopt($ch, CURLOPT_HEADER, 0);// , ,1 ,0
curl_setopt($ch, CURLOPT_REFERER, $http_url);
// , 0
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_PROXY,'127.0.0.1:8888');
// curl_setopt($ch, CURLOPT_ENCODING, "");
// curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
//
$output = curl_exec($ch);
if($output === FALSE)
{
echo "<br/>","cUrl Error:".curl_error($ch);
}else{
return $output;
}
// cURL
curl_close($ch);
}
$temp = array();
$temp['title'] = iconv( "utf-8", "gb2312//IGNORE" , " ");
$temp['ly'] = iconv( "utf-8", "gb2312//IGNORE" , " ");
$temp['classid'] = iconv( "utf-8", "gb2312//IGNORE" , "7159");
$temp['newssort'] = iconv( "utf-8", "gb2312//IGNORE" , "1");
$temp['panduan'] = iconv( "utf-8", "gb2312//IGNORE" , "0");
$temp['submit_button'] = iconv( "utf-8", "gb2312//IGNORE" , " ");
$temp['addr'] = iconv( "utf-8", "gb2312//IGNORE" , "bjcanyin");
$temp['ContentBg'] = "";
$temp['newss'] = iconv( "utf-8", "gb2312//IGNORE" , htmlspecialchars_decode("<p> </p><p><img alt=\"\"
src=\" http://localhost/super/Uploads/img/2017-08-10/598c145a9527e.jpg\" style=\"height:243px; width:324px\" /></p>", ENT_QUOTES));
$cookie_file = dirname(__FILE__)."/jdzj.tmp";
$sumbit_url = "http://***/news/***.asp";
$http_url="http://***/news/***.asp?act=addok";
$img = curl_form($temp,$http_url,$sumbit_url,$cookie_file);
var_dump($img);
PS:PHP curl 옵션 에 대한 자세 한 설명 은 참고 하 시기 바 랍 니 다https://www.jb51.net/article/39331.htm더 많은 PHP 관련 내용 에 관심 이 있 는 독자 들 은 본 사이트 의 주 제 를 볼 수 있다.
본 논문 에서 말 한 것 이 여러분 의 PHP 프로 그래 밍 에 도움 이 되 기 를 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
laravel에 yo에서 angularJs&coffeescript를 사용할 수 있도록 한다.먼저 yo 명령을 사용할 수 있어야하므로 아래에서 설치 global에 설치한 곳에서 laravel의 프로젝트 루트로 이동. 클라이언트 코드를 관리하는 디렉토리를 만들고 이동합니다. 클라이언트 환경 만들기 이것으로 히...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.