Example 1 — Append a Local File to a Remote Log
Add the contents of a small local file to the end of a remote log. The host and login are placeholders.
<?php
$ftp = ftp_connect("ftp.example.com");
ftp_login($ftp, "demo_user", "demo_pass");
if (ftp_append($ftp, "logs/app.log", "today.log", FTP_ASCII)) {
echo "Log appended.", PHP_EOL;
} else {
echo "Could not append.", PHP_EOL;
}
ftp_close($ftp); How It Works
- We connect and log in to the server.
- ftp_append() sends today. log and adds it to the end of logs/app.log.
- FTP_ASCII is used because log files are plain text.
- The script prints a message based on the true or false result.

