1, 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 passwordcurl_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, 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 passwordcurl_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, HTTPS$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;
Curl upload, download, HTTPS login