<?php // 打开文件 $file = ‘somefile.txt‘; $fp = fopen($file, ‘r‘); // 连接FTP $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // 上传 if(ftp_fput($conn_id, $file, $fp, FTP_ASCII)) { echo "Successfully uploaded $file\n"; } else { echo "There was a problem while uploading $file\n"; } // 退出 ftp_close($conn_id); fclose($fp); ?>
要使用这些 FTP 相关函数,在编译的时候请添加 --enable-ftp 选项。
时间: 2024-10-24 06:08:30