ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.


FTP Upload

This codesnippet can be used to login into a FTP server, and then upload a file. Common use might be for backup purposes on a off-site FTP server.

// Open FTP connection
$conn_id ftp_connect($ftp_server);

// Login with username and password
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// Check the connection
if ((!$conn_id) || (!$login_result)) {
"FTP connection has failed!";
"Attempted to connect to $ftp_server for user $ftp_user_name";
    } else {
"Connected to $ftp_server, for user $ftp_user_name";

// Upload the file
$upload ftp_put($conn_id$destination_file$source_fileFTP_BINARY);

// Check upload status
if (!$upload) {
"FTP upload has failed!";
    } else {
"Uploaded $source_file to $ftp_server as $destination_file";

// Close the FTP connection

2 Responses to “FTP Upload”

  1. Nino Says:

    Copied from ?

  2. ragnar Says:

    yep, kinda sure he did….

Leave a Reply