// FTP服务器信息$ftp_server = "ftp.example.com";$ftp_username = "your_username";$ftp_password = "your_password";$local_file = "path/to/your/local/file.txt"; // 本地文件路径$remote_file = "/path/to/remote/file.txt"; // 远程文件路径(相对于FTP根目录)// 连接到FTP服务器$conn_id = ftp_connect($ftp_server);if (!$conn_id) { die("无法连接到 $ftp_server : " . ftp_error());}// 登录到FTP服务器if (@ftp_login($conn_id, $ftp_username, $ftp_password) === false) { die("无法登录到 $ftp_server : " . ftp_error());}// 上传文件到FTP服务器if (ftp_put($conn_id, $remote_file, $local_file, FTP_BINARY) === false) { die("无法上传文件: " . ftp_error());} else { echo "文件上传成功!";}// 关闭FTP连接ftp_close($conn_id);