We accelerate websites

15 days free trial Sign up

Media Acceleration Stream to the world

15 days free trial Sign up

Extensive Network Excellent world coverage

PHP storage integration - an example

An example of storage integration using PHP FTP

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

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

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     = "push-11.cdnsun.com";
$ftp_user_name  = "u932732920398";
$ftp_user_pass  = "CnJn3k11K!ko9";
$file           = "image.jpeg"; // to be uploaded
$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 for more details.

 
 _    _     _____     _____     ______  
| \  / ||  |  ___||  /  ___||  /_   _// 
|  \/  ||  | ||__   | // __     -| ||-  
| .  . ||  | ||__   | \\_\ ||   _| ||_  
|_|\/|_||  |_____||  \____//   /_____// 
`-`  `-`   `-----`    `---`    `-----`  
                                        
Europe
  • Amsterdam
  • Athens
  • Baku
  • Budapest
  • Copenhagen
  • Dubai
  • Frankfurt
  • Helsingborg
  • Karlskrona
  • Khabarovsk
  • Kharkov
  • Kiev
  • Kungalv
  • Lisbon
  • London
  • Madrid
  • Milan
  • Moscow
  • Odessa
  • Oslo
  • Paris
  • Polevskoy
  • Rostov-on-Don
  • Saint Petersburg
  • Stockholm
  • Tel Aviv-Yafo
  • Ufa
  • Zagreb
America
  • Arlington
  • Atlanta
  • Bogota
  • Buenos Aires
  • Chicago
  • Dallas
  • Denver
  • Green Bay
  • Los Angeles
  • Miami
  • Montreal
  • New York
  • Phoenix
  • Portland
  • Provo
  • Queretaro
  • Reston
  • Sacramento
  • San Jose
  • Sao Paulo
  • Seattle
  • Toronto
  • Washington
Contact
  • e-mail: info@cdnsun.com
  • skype: cdnsun.com
  • phone: +1 844 300 9206
  • phone: +420 776 256 872
Blog Twitter LinkedIn Facebook CrunchBase Google+ / Google plus Foursquare Pinterest