Skip to content

Instantly share code, notes, and snippets.

@cp6
Created October 22, 2018 08:03
Show Gist options
  • Save cp6/62aefe9450ee9b88049aab9950e6223e to your computer and use it in GitHub Desktop.
Save cp6/62aefe9450ee9b88049aab9950e6223e to your computer and use it in GitHub Desktop.
BunnyCDN PHP FTP upload
<?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