Automatic FTP update of PHP implementation files

Source: Internet
Author: User
Tags echo date
PHP implementation of the use of FTP automatically update the upload file code, there is a need for friends, you can refer to the next.

Complete code.

Mirror Update

'; Exit;} echo "Connected to $host.
@ $result =ftp_login ($conn, $user, $password); if (! $result) {echo ' Error: User $user Login failed.
"; Ftp_quit ($conn); Exit } echo "Login as $user
"; Check file times to see if a update is required echo ' Checking file time ... '; if (file_exists ($localfile)) {$localtime =filetime ($localfile); Echo ' Local file last updated '; echo Date (' G:i j-m-y ', $localtime); Echo '
'; } else $localtime = 0; $remotetime =ftp_mdtm ($conn, $remotefile);//Gets the modified time function of the remote file if (! ( $remotetime >=0) {echo ' can/' t access remote file time.
'; $remotetime = $localtime +1; Make sure to update} else {echo ' Remote file last updated '; echo Date (' G:i j-m-y ', $remotetime); Echo '
'; } if (! ( $remotetime > $localtime) {echo ' Local copy is up to date.
'; Exit }//download file echo ' Getting file from server ....
'; $FP =fopen ($localfile, ' w '); if (! $success =ftp_fget ($conn, $FP, $remotefile)); {echo ' error:could not download file '; Ftp_quit ($conn); Exit } fclose ($FP); echo "File download successfully"; Close connection to host Ftp_quit ($conn), usage of//fget () function://ftp_get ($conn, $localfile, $remotefile);? >
  • 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.