Home > Backend Development > PHP Tutorial > 获取服务器文件时间数据失败,挟制+1后,仍然无法下载,请指点。

获取服务器文件时间数据失败,挟制+1后,仍然无法下载,请指点。

WBOY
Release: 2016-06-13 11:58:00
Original
998 people have browsed it

获取服务器文件时间数据失败,强制+1后,仍然无法下载,请指点。。

<br />$host = 'ftp.mozilla.org';<br />        $user = '';<br />        $password = '';<br />        $remotefile = '/pub/mozilla.org/firefox/releases/30.0b7/linux-x86_64/en-US/firefox-30.0b7.tar.bz2';<br /><br />        $localfile = '/home/username/firefox-29.0.1.tar.bz2';<br /><br /> $conn = ftp_connect($host);<br /><br />  $remotetime = ftp_mdtm($conn, $localfile);<br />            if(!($remotetime) >= 0){<br />                echo 'Can\'t access remote file time.<br />';<br />                $remotetime = $localtime +1;}<br /><br />   $fp = fopen($localfile, 'w');<br />            if(!$success = ftp_fget($conn, $fp, $remotefile, FTP_BINARY)){<br />                echo 'Error: Could not download file';<br />                ftp_quit($conn);<br /><br />该代码无法获得服务器文件的时间,也无法下载。真是奇怪,请指点。 
Copy after login

------解决方案--------------------
有登录ftp吗? ftp_login($conn,$user, $password);  
Copy after login

------解决方案--------------------
ftp 是有匿名用户的
$url = 'ftp.mozilla.org';<br />$ftp = ftp_connect($url); //连接 ftp 服务器<br />ftp_login($ftp, 'anonymous', ''); //用匿名用户登录<br />$list = ftp_nlist($ftp, '/'); //取得根目录的文件列表<br />print_r($list);
Copy after login
Array<br />(<br />    [0] => /README<br />    [1] => /index.html<br />    [2] => /pub<br />)<br /><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template