Assume that you need to upload on ftp the image.jpeg file to the public directory on your server.
An example of data that will be provided by a SkyparkCDN representative after your SkyStorage has been created:
- Server hostname - 123456789.origin.worldcdn.net
- Username - 123456789
- Password - abcd
And that you would like to upload the file image.jpeg to the public directory on your storage.
Please refer to the following code in PHP.
<?php $ftp_server = "<strong>123456789.origin.worldcdn.net</strong>"; $ftp_user_name = "<strong>123456789</strong>"; $ftp_user_pass = "<strong>abcd</strong>"; $file = "<strong>image.jpeg</strong>"; // to be uploaded $remote_file = "<strong>public/image.jpeg</strong>"; // 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); ?>
Refer to the PHP FTP for more details.