當前位置:首頁 » 文件管理 » ftp連接代碼

ftp連接代碼

發布時間: 2022-12-25 07:23:08

1. ftp錯誤代碼530,這是什麼意思要怎麼解決

您好!FTP報錯530一般會出現三種情況。
1、530 Login incorrect:這種情況,一般都是您的賬號的信息有誤,比如您的ftp地址,ftp賬號,ftp密碼以及您的埠方面有問題導致的報錯這個,那麼解決的方案也是非常的簡單,找到您正確的信息鏈接,即可正常的登錄。
2、530 Sorry, the maximum number of clients (3) from your host are already connected:這種情況從報錯的意思是說:對不起,最大客戶數(3)從你的主機已經連接,那麼出現的這個原因就是您本地的ftp工具的問題,或者是您本地的連接質量不好導致的,解決的方案更換ftp工具從新鏈接或者是暫停關閉ftp工具 從新登陸鏈接即可解決。
3、530 Not logged in, home directory does not exist:出現這樣的情況一般是伺服器的硬碟掛掉了,或者是該用戶目錄不存在導致的,具體的解決方案聯系空間商即可。
一般出現最多的就是以上幾種情況。

2. FTP連接時出現錯誤代碼10061,如何解決

請檢查你是否防火牆被禁止或者安裝有Mcafee邁克菲(網名:麥咖啡),如果安裝有請打開Mcafee邁克菲(網名:麥咖啡)殺毒軟體控制台,將 訪問保護、緩沖區溢出保護、兩項臨時禁止掉,等FTP傳送完畢在開啟!!!

肯定這兩項裡面為了安全保護,禁止掉了,沒有仔細查看防禦選項。

WinSock 2.0 -- OpenSSL 0.9.7d 2004-03-17
[左] 正在連接到 ****** -> IP=**.**.**.*** PORT=21
[左] 連接失敗 (10061: 連接被拒)
[左] 正在延遲 11 秒, 之後將嘗試第 1 次重新連接

3. Ftp 錯誤代碼 550,如何解決

FTP連接過程中,提示530 Login authentication failed錯誤是因為填寫錯了ftp密碼。
解決方法:
登陸客戶中心,客戶中心 > 會員中心 > 產品與服務(不同的主機提供商可能不同僅供參考)進入購買的那個套餐,下面有個登陸詳情然後輸入新密碼就行了,這樣ftp就可以用了。
FTP登錄常見提示錯誤:
1.connected. waiting for response. 220 serv-u ftp server v4.0 for winsock ready...
user anonymous 530 sorry, no anonymous access allowed. quit
不允許匿名登錄
2.connected. waiting for response. 220 serv-u ftp server v4.0 for winsock ready...
user test 331 user name okay, need password. pass xxxxxx 530 not logged in. quit 一般是密碼輸入錯誤時出現的信息。
3.connecting to xxx.xxx.xxx.xxx, port 21 error: connection timed out
這個表明對方未開機,也可能是對方不在能訪問的范圍內。可能小區的伺服器檢修中。
4.connecting to xxx.xxx.xxx.xxx port 21 error: connection refused
這個一般表明對方已開機,但未開啟ftp服務(沒有開serv-u),也可能為對方不提供在這個埠上的服務
5.connecting to xxx.xxx.xxx.xxx, port 21 connected. waiting for response. disconnected from server. connection attempt failed. waiting for retry...
出現極有可能是重試時間定的太短被伺服器封了。
6.connecting to xxx.xxx.xxx.xxx, port 21 connected. waiting for response. user xxx
331 user name okay, need password pass xxxxxx 530 not logged in, unauthorized ip address. quit
沒有登記ip,或者登記的ip和現在的不一樣,重新登記即可。
7.227 entering passive mode (218,3,87,224,10,232) retr hfdx-tsoaf.sub.rar 550 sorry, insufficient credit for download - upload first.
傳輸已失敗.傳輸隊列已完成但流量不夠了,重新購買。

4. FTP主動,被動模式----附代碼

http://blog.csdn.net/wumenglu1018/article/details/54233826

主動模式:

被動模式:

主動FTP:
命令連接:客戶端 大於1024 埠 -> 伺服器 21 埠
數據連接:客戶端 大於1024 埠 <- 伺服器 20 埠

被動FTP:
命令連接:客戶端 大於1024 埠 -> 伺服器 21 埠
數據連接:客戶端 大於1024 埠 -> 伺服器 大於1024 埠

簡要總結:

辦法:

例:
Class FTPParam : FTP所需參數

Class FTPUtil: ftp工具類

5. vs code配置ftp連接遠程伺服器實現代碼文自動上傳

1.在vscode應用商店中搜索拓展sftp插件,然後進行安裝。
2.安裝完成後重啟窗口,按快捷鍵Ctrl+shift+p,輸入sftp:config回車進入配置文件。

3.修改配置文件如下:

6. java編寫FTP連接報錯java.net.ConnectException: Connection refused: connect FTP

你用的FTPClient引入不對吧,我們項目上都是用的

import org.apache.commons.net.ftp.FTPClient;

import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;

下面是我們項目上用到的FTP的實現代碼(FTP需要先連接,再登錄,之後就是校驗登錄是否成功),具體代碼如下:

/**
*獲取FTPClient對象
*
*@paramftpHostFTP主機伺服器
*@paramftpPasswordFTP登錄密碼
*@paramftpUserNameFTP登錄用戶名
*@paramftpPortFTP埠默認為21
*@returnFTPClient
*@throwsException
*/
(StringftpHost,StringftpUserName,
StringftpPassword,intftpPort)throwsException{
try{
FTPClientftpClient=newFTPClient();
ftpClient.connect(ftpHost,ftpPort);//連接FTP伺服器
ftpClient.login(ftpUserName,ftpPassword);//登陸FTP伺服器
if(!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())){
logger.error("未連接到FTP,用戶名或密碼錯誤!");
ftpClient.disconnect();
returnnull;
}else{
logger.info("FTP連接成功!");
returnftpClient;
}
}catch(){
logger.error("FTP的IP地址可能錯誤,請正確配置!");
throwsocketException;
}catch(IOExceptionioException){
logger.error("FTP的埠錯誤,請正確配置!");
throwioException;
}
}

7. FTP 信息代碼全解

120 Service ready in nnn minutes.
服務在NNN時間內可用
125 Data connection already open; transfer starting.
數據連接已經打開,開始傳送數據.

150 File status okay; about to open data connection.
文件狀態正確,正在打開數據連接.

200 Command okay.
命令執行正常結束.

202 Command not implemented, superfluous at this site.
命令未被執行,此站點不支持此命令.

211 System status, or system help reply.
系統狀態或系統幫助信息回應.

212 Directory status.
目錄狀態信息.

213 File status.
文件狀態信息.

214 Help message.On how to use the server or the meaning of a particular non-standard command. This reply is useful only to the human user. 幫助信息。關於如何使用本伺服器或特殊的非標准命令。此回復只對人有用。

215 NAME system type. Where NAME is an official system name from the list in the Assigned Numbers document.
NAME系統類型。

220 Service ready for new user.
新連接的用戶的服務已就緒

221 Service closing control connection.
控制連接關閉

225 Data connection open; no transfer in progress.
數據連接已打開,沒有進行中的數據傳送

226 Closing data connection. Requested file action successful (for example, file transfer or file abort).
正在關閉數據連接。請求文件動作成功結束(例如,文件傳送或終止)

227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
進入被動模式

230 User logged in, proceed. Logged out if appropriate.
用戶已登入。 如果不需要可以登出。

250 Requested file action okay, completed.
被請求文件操作成功完成

257 "PATHNAME" created.
路徑已建立

331 User name okay, need password.
用戶名存在,需要輸入密碼

332 Need account for login.
需要登陸的賬戶 西門吐血

350 Requested file action pending further information
對被請求文件的操作需要進一步更多的信息

421 Service not available, closing control connection.This may be a reply to any command if the service knows it must shut down.
服務不可用,控制連接關閉。這可能是對任何命令的回應,如果服務認為它必須關閉

425 Can`t open data connection.
打開數據連接失敗

426 Connection closed; transfer aborted.
連接關閉,傳送中止。

450 Requested file action not taken.
對被請求文件的操作未被執行

451 Requested action aborted. Local error in processing.
請求的操作中止。處理中發生本地錯誤。

452 Requested action not taken. Insufficient storage space in system.File unavailable (e.g., file busy).
請求的操作沒有被執行。 系統存儲空間不足。 文件不可用

500 Syntax error, command unrecognized. This may include errors such as command line too long.
語法錯誤,不可識別的命令。 這可能是命令行過長。

501 Syntax error in parameters or arguments.
參數錯誤導致的語法錯誤

502 Command not implemented.
命令未被執行

503 Bad sequence of commands.
命令的次序錯誤。

504 Command not implemented for that parameter.
由於參數錯誤,命令未被執行

530 Not logged in.
沒有登錄

532 Need account for storing files.
存儲文件需要賬戶信息 西門吐血

550 Requested action not taken. File unavailable (e.g., file not found, no access).
請求操作未被執行,文件不可用。

551 Requested action aborted. Page type unknown.
請求操作中止,頁面類型未知

552 Requested file action aborted. Exceeded storage allocation (for current directory or dataset).
對請求文件的操作中止。 超出存儲分配

553 Requested action not taken. File name not allowed
請求操作未被執行。 文件名不允許

這種錯誤跟http協議類似,大致是:
2開頭--成功
3開頭--許可權問題
4開頭--文件問題
5開頭--伺服器問題
對大家最有用的:
421:一般出現在連接數多,需稍後在接;
530:密碼錯誤;
550:目錄或文件已經被刪除。

8. 請問,php連接FTP伺服器代碼怎樣寫,希望要具體點,說明步驟,謝謝,非常急

如果是通過FTP下載文件倒是可以試試:
file_get_contents('ftp://FTP用戶名@FTP密碼@IP或域名');

9. 請解釋一下FTP連接的命令及響應

FTP命令
命令 描述
ABOR 中斷數據連接程序
ACCT <account> 系統特權帳號
ALLO <bytes> 為伺服器上的文件存儲器分配位元組
APPE <filename> 添加文件到伺服器同名文件
CDUP <dir path> 改變伺服器上的父目錄
CWD <dir path> 改變伺服器上的工作目錄
DELE <filename> 刪除伺服器上的指定文件
HELP <command> 返回指定命令信息
LIST <name> 如果是文件名列出文件信息,如果是目錄則列出文件列表
MODE <mode> 傳輸模式(S=流模式,B=塊模式,C=壓縮模式)
MKD <directory> 在伺服器上建立指定目錄
NLST <directory> 列出指定目錄內容
NOOP 無動作,除了來自伺服器上的承認
PASS <password> 系統登錄密碼
PASV 請求伺服器等待數據連接
PORT <address> IP 地址和兩位元組的埠 ID
PWD 顯示當前工作目錄
QUIT 從 FTP 伺服器上退出登錄
REIN 重新初始化登錄狀態連接
REST <offset> 由特定偏移量重啟文件傳遞
RETR <filename> 從伺服器上找回(復制)文件
RMD <directory> 在伺服器上刪除指定目錄
RNFR <old path> 對舊路徑重命名
RNTO <new path> 對新路徑重命名
SITE <params> 由伺服器提供的站點特殊參數
SMNT <pathname> 掛載指定文件結構
STAT <directory> 在當前程序或目錄上返回信息
STOR <filename> 儲存(復制)文件到伺服器上
STOU <filename> 儲存文件到伺服器名稱上
STRU <type> 數據結構(F=文件,R=記錄,P=頁面)
SYST 返回伺服器使用的操作系統
TYPE <data type> 數據類型(A=ASCII,E=EBCDIC,I=binary)
USER <username>> 系統登錄的用戶名

FTP響應碼

響應代碼 解釋說明
110 新文件指示器上的重啟標記
120 伺服器准備就緒的時間(分鍾數)
125 打開數據連接,開始傳輸
150 打開連接
200 成功
202 命令沒有執行
211 系統狀態回復
212 目錄狀態回復
213 文件狀態回復
214 幫助信息回復
215 系統類型回復
220 服務就緒
221 退出網路
225 打開數據連接
226 結束數據連接
227 進入被動模式(IP 地址、ID 埠)
230 登錄網際網路
250 文件行為完成
257 路徑名建立
331 要求密碼
332 要求帳號
350 文件行為暫停
421 服務關閉
425 無法打開數據連接
426 結束連接
450 文件不可用
451 遇到本地錯誤
452 磁碟空間不足
500 無效命令
501 錯誤參數
502 命令沒有執行
503 錯誤指令序列
504 無效命令參數
530 未登錄網路
532 存儲文件需要帳號
550 文件不可用
551 不知道的頁類型
552 超過存儲分配
553 文件名不允許

10. PHP登錄遠程FTP空間代碼

給你的演示代碼,有很多注釋,你試試就知道了



<?php
//配置數據
$ftp_server="";//FTP伺服器
$ftp_user_name="";//FTP用戶名
$ftp_user_pass="";//FTP用戶密碼
$ftp_up_dir="webspace/httpdocs/upload";//上傳到哪個目錄
$ftp_site_url="";//文件訪問URL地址
$admin="admin";//管理員用戶名
$adminpw="admin";//管理員密碼
session_start();
//退出登錄
if($_GET['action']=="logout"){
$_SESSION['pw']="";
}
//保存登錄狀態
if($_POST['pw']==$adminpw && $_POST['user']==$admin){
$_SESSION['pw']=$adminpw;
$_SESSION['user']=$admin;
}
if($_SESSION['pw']!=$adminpw || $_SESSION['user']!=$admin)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>請登錄</title>
</head>
<body>
<form action="<?php $n = explode('/',$_SERVER['PHP_SELF']); echo $n[count($n)-1]; ?>" method="post">
<label for="file">管理賬戶:</label><input type="text" name="user" id="user" /> <br>
<label for="file">管理密碼:</label><input type="password" name="pw" id="pw" />
<br />
<input type="submit" name="submit" value="Login" />
</form>
</body>
</html>
<?
exit();
}
if(!$_FILES)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FTP遠程上傳</title>
</head>
<body>
<form action="<?php $n = explode('/',$_SERVER['PHP_SELF']); echo $n[count($n)-1]; ?>" method="post"
enctype="multipart/form-data">
<label for="file">文件名稱:</label>
<input type="file" name="file" id="file" />
<input type="submit" name="submit" value="上傳" />
</form>
<p><a href="?action=logout">退出</a></p>
</body>
</html>
<?php
}
else
{
$file = date('y-m-d_').rand(1,999999999).'_'.$_FILES["file"]["name"];
// 連接FTP
$conn = ftp_connect($ftp_server);
$login_result = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
//改編目錄
ftp_chdir($conn,$ftp_up_dir);
// 上傳
if(ftp_put($conn, $file,$_FILES["file"]["tmp_name"] , FTP_ASCII)) {
$cue = "上傳文件 $file 成功.<br />文件訪問地址: <a href='$ftp_site_url$file' target='_blank'>$ftp_site_url".$file."</a>";
} else {
$cue = "上傳文件 $file 時出錯";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文件上傳結果</title>
</head>
<body>
<p><?php echo $cue; ?></p>
<p>
<form action="<?php $n = explode('/',$_SERVER['PHP_SELF']); echo $n[count($n)-1]; ?>" method="post"
enctype="multipart/form-data">
<label for="file">文件名稱:</label>
<input type="file" name="file" id="file" />
<input type="submit" name="submit" value="上傳" />
</form>
</p>
<p><a href="?action=logout">退出</a></p>
</body>
</html>
<?php
// 關閉FTP連接
ftp_close($conn);
}
?>
熱點內容
安卓系統怎麼用藍牙傳給蘋果手機 發布:2025-08-22 02:27:51 瀏覽:474
android獲取數組 發布:2025-08-22 02:24:04 瀏覽:645
徵型壓縮機 發布:2025-08-22 02:10:15 瀏覽:494
真空壓縮袋能上飛機嗎 發布:2025-08-22 02:10:01 瀏覽:94
怎麼刪除伺服器文件 發布:2025-08-22 02:04:07 瀏覽:168
爐石傳說威脅腳本投降 發布:2025-08-22 01:54:10 瀏覽:331
大大哇腳本 發布:2025-08-22 01:49:32 瀏覽:94
python2pip 發布:2025-08-22 01:48:56 瀏覽:388
php和null 發布:2025-08-22 01:48:49 瀏覽:964
安卓手機怎麼強制解鎖 發布:2025-08-22 01:48:48 瀏覽:81