We accelerate websites

30 days free trial Sign up

Media Acceleration Stream to the world

30 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
  • Bucharest
  • Budapest
  • Frankfurt
  • Istanbul
  • Kharkov
  • Kiev
  • Krasnoyarsk
  • London
  • Lvov
  • Madrid
  • Milan
  • Moscow
  • Odessa
  • Oslo
  • Paris
  • Stockholm
  • Trondheim
America
  • Atlanta
  • Bogota
  • Buenos Aires
  • Chicago
  • Dallas
  • Denver
  • Los Angeles
  • Miami
  • Montreal
  • New York
  • Provo
  • Queretaro
  • 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