An error occurred while obtaining the time data of the server file. after force + 1, the file cannot be downloaded. please advise

Source: Internet
Author: User
An error occurred while obtaining the time data of the server file. after force + 1, the file cannot be downloaded. please advise
$ Host = 'ftp .mozilla.org '; $ user = ''; $ password =''; $ remotefile ='/pub/others $ localfile = '/home/username/firefox-29.0.1.tar.bz2 '; $ conn = ftp_connect ($ host); $ remotetime = ftp_mdtm ($ conn, $ localfile); if (! ($ Remotetime)> = 0) {echo 'can \'t access remote file time.
'; $ Remotetime = $ localtime + 1;} $ fp = fopen ($ localfile, 'w'); if (! $ Success = ftp_fget ($ conn, $ fp, $ remotefile, FTP_BINARY) {echo 'Error: cocould not download file'; ftp_quit ($ conn ); this code cannot get the server file Time or download. This is really strange. please advise.


Reply to discussion (solution)

Var_dump ($ remotetime );
See what

Have you logged on to ftp? Ftp_login ($ conn, $ user, $ password );

Have you logged on to ftp? Ftp_login ($ conn, $ user, $ password );


$ Result = @ ftp_login ($ conn, $ user, $ password );
If (! $ Result ){
Echo "Error: cocould not log on as $ user
";
Ftp_quit ($ conn );
Exit;
}
Yes, but the logon fails. How do I write this user name and password? The user name and password are not required for ftp download in firefox, but ftp_login requires the user name and password. I don't know how to do it. please give me some advice. they didn't even care about me when asked in oschina. maybe they thought the problem was too low ..

Var_dump ($ remotetime );
See what


You cannot use ftp_login to log on .. The user name and password are not required for ftp download in firefox, but the ftp_login function requires the user name and password. I don't know how to do it. please give me some advice. they didn't even care about me when asked in oschina. maybe they thought the problem was too low ..

It doesn't matter with the browser either. that's what the browser remembers.

Ftp has anonymous users.

$ Url = 'ftp .mozilla.org '; $ ftp = ftp_connect ($ url); // connect to the ftp server ftp_login ($ ftp, 'anonus us ',''); // log on to $ list = ftp_nlist ($ ftp, '/') with an anonymous user; // Obtain the file list print_r ($ list) in the root directory );
Array(    [0] => /README    [1] => /index.html    [2] => /pub)

If you know the ftp directory structure, you can use
File_get_contents read
File_put_contents write

If you know the ftp directory structure, you can use
File_get_contents read
File_put_contents write


Hello, I listened to your suggestion and found that the php browser was loaded for a long time and displayed a blank page.
I believe there is no problem with your code, but it also shows a blank page. how can I solve this problem? it should not be a problem with the code.
My system Debian + Netbeans has built-in Php, and the browser is iceweasel

Is your ftp extension loaded?

No problem with my code, you can access ftp://ftp.mozilla.org with a browser
Slow speed is normal

Is your ftp extension loaded?

No problem with my code, you can access ftp://ftp.mozilla.org with a browser
Slow speed is normal


Hello, moderator. my ftp is in enabled state. let me check it out.

It seems that the server data cannot be used, just as your code also shows a blank page ..

Is your ftp extension loaded?

No problem with my code, you can access ftp://ftp.mozilla.org with a browser
Slow speed is normal



I tried to connect to other sites, but the following results were obtained, so I could not get the server file Time or download the file.
Mirror Update Connected to ftp.debian.org.
Logged in as anonymous
Checking file time...
Local file last updated14: 02 24-May-2014
Can't access remote file time.
Getting file from server...
Error: cocould not download file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.