PHP 通过curl下载ftp文件,怎么设置端口号
如果我要访问的端口号是8080,要怎么设置。$curlobj=curl_init();curl_setopt($curlobj,CURLOPT_URL,"ftp://17...
如果我要访问的端口号是8080,要怎么设置。
$curlobj = curl_init();
curl_setopt($curlobj,CURLOPT_URL,"ftp://172.19.71.63/Flipped.2010.BluRay.720p.DTS.x264-CHD.sample.mkv");
curl_setopt($curlobj,CURLOPT_HEADER,0);
curl_setopt($curlobj,CURLOPT_RETURNTRANSFER,0);
//time out after 300s
curl_setopt($curlobj,CURLOPT_TIMEOUT,500);
//通过这个函数设置ftp的用户名和密码,没设置就不需要!
//curl_setopt($curlobj,CURLOPT_USERPWD,":");
//sets up the output file
$outfile = fopen('fuck.mkv','wb'); //保存到本地文件的文件名
curl_setopt($curlobj,CURLOPT_FILE,$outfile);
$rtn = curl_exec($curlobj);
fclose($outfile);
if(!curl_errno($curlobj)){
echo "RETURN: ".$rtn;
}else{
echo 'Curl:error: '.curl_errno($curlobj);
}
curl_close($curlobj); 展开
$curlobj = curl_init();
curl_setopt($curlobj,CURLOPT_URL,"ftp://172.19.71.63/Flipped.2010.BluRay.720p.DTS.x264-CHD.sample.mkv");
curl_setopt($curlobj,CURLOPT_HEADER,0);
curl_setopt($curlobj,CURLOPT_RETURNTRANSFER,0);
//time out after 300s
curl_setopt($curlobj,CURLOPT_TIMEOUT,500);
//通过这个函数设置ftp的用户名和密码,没设置就不需要!
//curl_setopt($curlobj,CURLOPT_USERPWD,":");
//sets up the output file
$outfile = fopen('fuck.mkv','wb'); //保存到本地文件的文件名
curl_setopt($curlobj,CURLOPT_FILE,$outfile);
$rtn = curl_exec($curlobj);
fclose($outfile);
if(!curl_errno($curlobj)){
echo "RETURN: ".$rtn;
}else{
echo 'Curl:error: '.curl_errno($curlobj);
}
curl_close($curlobj); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询