Created
October 22, 2018 08:03
-
-
Save cp6/62aefe9450ee9b88049aab9950e6223e to your computer and use it in GitHub Desktop.
BunnyCDN PHP FTP upload
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 | |
| function uploadFTP($server, $username, $password, $file_to_upload, $save_file_as){ | |
| $connection = ftp_connect($server); | |
| if (@ftp_login($connection, $username, $password)){ | |
| // connection success | |
| }else{ | |
| return "Error connecting to $server"; | |
| } | |
| ftp_pasv($connection, true); | |
| ftp_put($connection, $save_file_as, $file_to_upload, FTP_BINARY); | |
| ftp_close($connection); | |
| return "Uploaded $file_to_upload to $server and saved as $save_file_as"; | |
| } | |
| //call to upload a file | |
| uploadFTP("storage.bunnycdn.com", "USERNAME", "PASSWORD", "filetoupload.zip", "saveitas.zip"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment