What are potential pitfalls to be aware of when using FTP functions in PHP for file uploads?

One potential pitfall when using FTP functions in PHP for file uploads is not properly handling errors or checking for successful uploads. To avoid this issue, always check the return value of the FTP upload function to ensure the file was successfully uploaded.

// Connect to FTP server
$conn = ftp_connect('ftp.example.com');
ftp_login($conn, 'username', 'password');

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

// Close FTP connection
ftp_close($conn);