What are best practices for specifying file paths in PHP scripts for FTP transfers?

When specifying file paths in PHP scripts for FTP transfers, it is important to use absolute paths to ensure the correct files are accessed regardless of the current working directory. This helps prevent errors and ensures the script functions correctly across different environments. Additionally, it is recommended to use forward slashes (/) as directory separators for better compatibility.

// Specify absolute file paths for FTP transfers
$localFilePath = '/path/to/local/file.txt';
$remoteFilePath = '/path/to/remote/file.txt';

// Connect to FTP server and transfer file
$ftp = ftp_connect('ftp.example.com');
ftp_login($ftp, 'username', 'password');
ftp_put($ftp, $remoteFilePath, $localFilePath, FTP_BINARY);

// Close FTP connection
ftp_close($ftp);