當我嘗試使用PHP的ftp_put功能上傳文件,以前它是示數:PHP ftp_put警告警告:ftp_put()[function.ftp-放]:類型設置爲我在
Warning: ftp_put() [function.ftp-put]: No data connection
現在,我試圖把被動模式上:
ftp_pasv($conn_id, true);
然後是錯誤:
Warning: ftp_put() [function.ftp-put]: Type set to I. in
ftp_login正確完成,它說成功。
現在,它賦予了新的警告:警告:ftp_put() [function.ftp-put]: abc.txt: Cannot open or remove a file containing a running program.
任何想法,爲什麼文件沒有tranferring?
謝謝!
這裏是我的代碼片段:
$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);
請問您可以發佈您的代碼嗎? – Tapos 2011-05-27 04:24:55
您是否將流指定爲第一個參數? – alex 2011-05-27 04:26:27
現在增加.. pl進一步指導我 – 2011-05-27 04:30:28