Storage integration using PHP FTP

Introduction

Let's assume that your CDN storage has the following properties.

  • Server hostname - push-11.cdnsun.com
  • Username - u932732920398
  • Password - CnJn3k11K!ko9

And that you would like to upload a file image.jpeg to the public directory on your CDN storage.

Storage integration using PHP FTP

Please refer to the following PHP code.

<?php
$ftp_server     = "push-11.cdnsun.com";
$ftp_user_name  = "u932732920398";
$ftp_user_pass  = "CnJn3k11K!ko9";
$file           = "image.jpeg"; 
$remote_file    = "public/image.jpeg";

// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if(ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) 
{
    echo "successfully uploaded $file\n";
    exit;
} 
else 
{
    echo "There was a problem while uploading $file\n";
    exit;
}

// close the connection
ftp_close($conn_id);
?>

Please refer to the PHP FTP documentation for more details.

What next?

Read about the following topics.

Contact Us

 _____     __   __   _    _   
|  __ \\   \ \\/ // | |  | || 
| |  \ ||   \ ` //  | |/\| || 
| |__/ ||    | ||   |  /\  || 
|_____//     |_||   |_// \_|| 
 -----`      `-`'   `-`   `-`