当我尝试使用
PHP的ftp_put函数上传文件时,之前它是错误的:
原文链接:https://www.f2er.com/php/138090.html警告:ftp_put()[function.ftp-put]:无数据连接
现在,我尝试将被动模式放在:
ftp_pasv($conn_id,true);
然后出现错误:
警告:ftp_put()[function.ftp-put]:键入设置为I. in
ftp_login已正确完成,并表示已成功完成.
现在它给出了新警告:警告:ftp_put()[function.ftp-put]:abc.txt:无法打开或删除包含正在运行的程序的文件.
任何想法,为什么文件不转移?
谢谢 !
这是我的代码片段:
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id,$ftp_user_name,$ftp_user_pass) or die("You do not have access to this ftp server!"); if ((!$conn_id) || (!$login_result)) { // wont ever hit this,b/c of the die call on ftp_login echo "<span style='color:#FF0000'><h2>FTP connection has Failed! <br />"; echo "Attempted to connect to $ftp_server for user $ftp_user_name</h2></span>"; exit; } else { //echo "Connected to $ftp_server,for user $ftp_user_name <br />"; } //turn passive mode on ftp_pasv($conn_id,true); $upload = ftp_put($conn_id,$destination_file.$name,$filename,FTP_BINARY); if (!$upload) { echo "<span style='color:#FF0000'><h2>FTP upload of $filename has Failed!</h2></span> <br />"; } else { echo 'Uploaded'; } ftp_close($conn_id);