What are the potential reasons for a file not being uploaded successfully using ftp_put in PHP?

The potential reasons for a file not being uploaded successfully using ftp_put in PHP could include incorrect file paths, insufficient permissions on the server, or network connectivity issues. To solve this issue, double-check the file path, ensure the server has write permissions for the destination folder, and verify that there are no network interruptions during the upload process.

$conn_id = ftp_connect("ftp.example.com");
$login_result = ftp_login($conn_id, "username", "password");

if (ftp_put($conn_id, "remote/path/to/file.txt", "local/path/to/file.txt", FTP_BINARY)) {
    echo "File uploaded successfully";
} else {
    echo "Failed to upload file";
}

ftp_close($conn_id);