Connect and Upload to FTP server with PHP

$ftp_server = “”; /// or you can use ip address
$ftp_conn = ftp_connect($ftp_server,”21″) or die(“Could not connect to $ftp_server”);
$login = ftp_login($ftp_conn, “user”, “password”);

$file = “t.html”;

// upload file
if (ftp_put($ftp_conn, “iman.txt”, $file, FTP_ASCII))
echo “Successfully uploaded $file.”;
echo “Error uploading $file.”;

// close connection

FTP port by default is 21 but you can change it from the server and use an other port in you code !

One thought on “Connect and Upload to FTP server with PHP

  1. I got this website from my buddy who shared with me on the topic of this website and now this time I am visiting this site and reading very informative posts here.|

Leave a Reply

Your email address will not be published. Required fields are marked *