What are some common pitfalls to avoid when working with FTP and special characters in PHP?

When working with FTP and special characters in PHP, a common pitfall to avoid is not properly encoding special characters before sending them to the FTP server. To solve this issue, you can use PHP's `rawurlencode()` function to encode special characters before sending them via FTP.

// Encode special characters before sending via FTP
$encoded_filename = rawurlencode($filename);

// Connect to FTP server and upload file with encoded filename
$ftp_server = 'ftp.example.com';
$ftp_user = 'username';
$ftp_pass = 'password';
$conn_id = ftp_connect($ftp_server);
ftp_login($conn_id, $ftp_user, $ftp_pass);
ftp_put($conn_id, $encoded_filename, $local_file, FTP_BINARY);
ftp_close($conn_id);