This article mainly introduces php curl upload, download, HTTPS Landing implementation code, the need for friends can refer to the following
1. Curl Download
$ch = Curl_init (); curl_setopt ($ch, Curlopt_url, "ftp://127.0.0.1/downtest.txt"); curl_setopt ($ch, curlopt_header,0); curl_setopt ($ch, curlopt_returntransfer,1); curl_setopt ($ch, curlopt_timeout,300); Set user name and password curl_setopt ($ch, Curlopt_userpwd, "yuejide:123456"); $outfile = fopen ("Test.txt", "WB"); curl_setopt ($ch, Curl_file, $outfile); $rtn = curl_exec ($ch); Fclose ($outfile); if (!curl_errno ($ch)) {echo $rtn;} else{echo ' curl error '. Curl_errno ($ch);} curl_close ($ch);
2. Curl Upload
$ch = Curl_init (); $localfile = "ftp01.php"; $fp = fopen ($localfile, ' R '); curl_setopt ($ch, Curlopt_url, "ftp://127.0.0.1/ftp01_upload.php"); curl_setopt ($ch, curlopt_header,0); curl_setopt ($ch, curlopt_returntransfer,1); curl_setopt ($ch, curlopt_timeout,300); Set user name and password curl_setopt ($ch, Curlopt_userpwd, "yuejide:123456"); curl_setopt ($ch, curlopt_upload,1); curl_setopt ($ch, Curlopt_infile, $fp); curl_setopt ($ch, Curlopt_infilesize,filesize ($localfile)); $rtn = curl_exec ($ch); Fclose ($FP); if (!curl_errno ($ch)) {echo "Upload successfully";} else{echo ' Curl_error ' Curl_error ($ch);} curl_close ($ch);
3. Curl HTTPS Login
$ch = Curl_init (); curl_setopt ($ch, Curlopt_url, "https://www.baidu.com"); curl_setopt ($ch, curlopt_returntransfer,1); Date_default_timezone_set (' PRC '); curl_setopt ($ch, curlopt_ssl_verifypeer,0); $output = curl_exec ($ch); Curl_close ($ch); Echo $output;