Created
June 18, 2018 02:48
-
-
Save rochow/92e76a03b29d0384679176ebf715ace1 to your computer and use it in GitHub Desktop.
Push a zip file to external server via FTP (handy for non-WP things, when on a dodgy connection etc)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$server = 'something.com'; | |
$ftp_user_name = 'username'; | |
$ftp_user_pass = 'password'; | |
$filename = 'June2Site.zip'; | |
$source = 'aaa/'.$filename; | |
$dest = '/new/'.$filename; | |
$mode = FTP_BINARY; // FTP_ASCII for text files (html, css, js etc) | |
$connection = ftp_ssl_connect ($server,24); | |
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass); | |
if (!$connection || !$login) { die('Connection attempt failed!'); } | |
$upload = ftp_put($connection, $dest, $source, $mode); | |
if (!$upload) { | |
echo 'FTP upload failed!'; | |
} else { | |
echo 'File uploaded!'; | |
} | |
ftp_close($connection); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment