What are some common pitfalls to avoid when using the ftp_put function in PHP?

One common pitfall to avoid when using the ftp_put function in PHP is not checking if the file transfer was successful. It is important to handle errors and validate the return value of ftp_put to ensure that the file was uploaded successfully.

// Example code snippet to check if the file transfer was successful
$conn = ftp_connect('ftp.example.com');
ftp_login($conn, 'username', 'password');

$upload = ftp_put($conn, 'remote_file.txt', 'local_file.txt', FTP_BINARY);

if ($upload) {
    echo "File uploaded successfully";
} else {
    echo "File upload failed";
}

ftp_close($conn);