- Code: Select all
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$file = "localfile.txt";
// upload file
if (ftp_put($ftp_conn, "serverfile.txt", $file, FTP_ASCII))
echo "Successfully uploaded $file.";
echo "Error uploading $file.";
// close connection
except of coarse with entering my own server info, i get the echo "Error uploading $file." and the only way it works is when i make the local file and the remote file having the same name, and even at this case the remote file is being overwritten by zero byte file size in my ftp server which is actually useless.
any help for this issue?