當前位置:首頁 » 文件管理 » 怎麼改ftp路徑

怎麼改ftp路徑

發布時間: 2022-02-24 14:00:09

Ⅰ 如何更改ftp用戶的ftp根目錄

搭建FTP
安裝vsftpd
vim /etc/vsftpd/vsftpd.conf
修改或添加
anon_root=/opt
/etc/init.d/vsftpd start
chkconfig vsftpd on

這里的anon_root=/opt 就是指定只能訪問opt下!!

Ⅱ ftp的路徑怎麼設置

問一下,你是想做ftp上傳下載么?

首先你需要安裝一個ftp服務端程序,啟動起來,然後下載一個ftp客戶端程序,測試能不能連接,首先這一塊兒需要測試通過。
代碼ftp上傳下載
2.1 上傳代碼:
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;

public class test {

private FTPClient ftp;
/**
*
* @param path 上傳到ftp伺服器哪個路徑下
* @param addr 地址
* @param port 埠號
* @param username 用戶名
* @param password 密碼
* @return
* @throws Exception
*/
private boolean connect(String path,String addr,int port,String username,String password) throws Exception {
boolean result = false;
ftp = new FTPClient();
int reply;
ftp.connect(addr,port);
ftp.login(username,password);
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
return result;
}
ftp.changeWorkingDirectory(path);
result = true;
return result;
}
/**
*
* @param file 上傳的文件或文件夾
* @throws Exception
*/
private void upload(File file) throws Exception{
if(file.isDirectory()){
ftp.makeDirectory(file.getName());
ftp.changeWorkingDirectory(file.getName());
String[] files = file.list();
for (int i = 0; i < files.length; i++) {
File file1 = new File(file.getPath()+"\\"+files[i] );
if(file1.isDirectory()){
upload(file1);
ftp.changeToParentDirectory();
}else{
File file2 = new File(file.getPath()+"\\"+files[i]);
FileInputStream input = new FileInputStream(file2);
ftp.storeFile(file2.getName(), input);
input.close();
}
}
}else{
File file2 = new File(file.getPath());
FileInputStream input = new FileInputStream(file2);
ftp.storeFile(file2.getName(), input);
input.close();
}
}
public static void main(String[] args) throws Exception{
test t = new test();
t.connect("", "localhost", 21, "yhh", "yhhazr");
File file = new File("e:\\uploadify");
t.upload(file);
}
}
2.2 下載代碼
這里沒有用到filter,如果用filter就可以過濾想要的文件。

public class Ftp {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Ftp ftp = new Ftp();
String hostname = "www.strawberry.com";
Integer port = 21;
String username = "username";
String password = "password";
String remote = "/c.txt";
String local = "/home/tin/LeonChen/FTP/";
try {
ftp.connect(hostname, port, username, password);
System.out.println("接收狀態:"+ftp.download(remote, local));
ftp.disconnect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

private FTPClient ftpClient = new FTPClient();

/*
* * 連接到FTP伺服器
* * @param hostname 主機名
* * @param port 埠
* * @param username 用戶名
* * @param password 密碼
* * @return 是否連接成功
* * @throws IOException
*/
private boolean connect(String hostname, int port, String username,
String password) throws IOException {
ftpClient.connect(hostname, port);
ftpClient.setControlEncoding("UTF-8");
if (FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
if (ftpClient.login(username, password)) {
return true;
}
}
disconnect();
return false;
}

/*
* 從FTP伺服器上下載文件,支持斷點續傳,上傳百分比匯報
*
* @param remote 遠程文件路徑
*
* @param local 本地文件路徑
*
* @return 上傳的狀態
*
* @throws IOException
*/
public DownloadStatus download(String remote, String local)
throws IOException {
// 設置被動模式
ftpClient.enterLocalPassiveMode();
// 設置以二進制方式傳輸
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
DownloadStatus result;
// 檢查遠程文件是否存在
FTPFile[] files = ftpClient.listFiles(new String(remote
.getBytes("UTF-8"), "iso-8859-1"));
if (files.length != 1) {
System.out.println("遠程文件不存在");
return DownloadStatus.Remote_File_Noexist;
}
long lRemoteSize = files[0].getSize();
String fildName = files[0].getName();
// 本地存在文件,進行斷點下載
File f = new File(local+fildName);
if (f.exists()) {
long localSize = f.length();
if (localSize >= lRemoteSize) {
System.out.println("本地文件大於遠程文件,下載中止");
return DownloadStatus.Local_Bigger_Remote;
}

// 進行斷點續傳,並記錄狀態
FileOutputStream out = new FileOutputStream(f, true);
ftpClient.setRestartOffset(localSize);
InputStream in = ftpClient.retrieveFileStream(new String(remote.getBytes("UTF-8"), "iso-8859-1"));
byte[] bytes = new byte[1024];
long step = lRemoteSize / 100;
long process = localSize / step;
int c;
while ((c = in.read(bytes)) != -1) {
out.write(bytes, 0, c);
localSize += c;
long nowProcess = localSize / step;
if (nowProcess > process) {
process = nowProcess;
if (process % 10 == 0)
System.out.println("下載進度:" + process);
// TODO 更新文件下載進度,值存放在process變數中
}
}
in.close();
out.close();
boolean isDo = ftpClient.completePendingCommand();
if (isDo) {
result = DownloadStatus.Download_From_Break_Success;
} else {
result = DownloadStatus.Download_From_Break_Failed;
}
} else {
OutputStream out = new FileOutputStream(f);
InputStream in = ftpClient.retrieveFileStream(new String(remote.getBytes("UTF-8"), "iso-8859-1"));
byte[] bytes = new byte[1024];
long step = lRemoteSize / 100;
long process = 0;
long localSize = 0L;
int c;
while ((c = in.read(bytes)) != -1) {
out.write(bytes, 0, c);
localSize += c;
long nowProcess = localSize / step;
if (nowProcess > process) {
process = nowProcess;
if (process % 10 == 0)
System.out.println("下載進度:" + process);
// TODO 更新文件下載進度,值存放在process變數中
}
}
in.close();
out.close();
boolean upNewStatus = ftpClient.completePendingCommand();
if (upNewStatus) {
result = DownloadStatus.Download_New_Success;
} else {
result = DownloadStatus.Download_New_Failed;
}
}
return result;
}

private void disconnect() throws IOException {
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
}

}

Ⅲ 如何修改FTP默認目錄

這個必須要在 FTP 伺服器上對 FTP 伺服器的配置文件進行修改才行(包括默認的上傳、下載主目錄,一般是 public,是否允許匿名登錄(anonymous)等)。

Ⅳ 怎麼改FTP下載的路徑

下次下載時,你先仔細地把出現的對話框讀一遍,機器會默認你現有的下載軟體,你看看是什麼,
至於下載的東西,對話框中會有下載路徑告訴你,
你把下載對話框中的東西都抄下來。
打開:我的電腦-C盤-
順著下載路徑就會找到你要看的東西,
有時下載 ,會讓你自己選擇下載地點。
不會很難,問問周圍的人,自己找些基礎的電腦書看一下,慢慢就會好,

Ⅳ windows12下怎麼在命令行模式下修改ftp默認路徑

首先執行ftp命令到ftp環境下,使用lcd 你要的目錄 即可

Ⅵ 如何修改FTP的物理路徑

發現問題,勇於提問

課堂上勇於提問是優等生渴望和追求知識的表現,他們知道高分是來自對知識的透徹理解和掌握。在學習的過程中,把沒有弄懂的問題通過提問,通過愛問,達到深入研究,仔細體會的目的。所以在學生群體中間,好問的學生佔有老師大量的資源,有一種得天獨厚的優勢,而不愛問的學生,就主動放棄了別人的幫助,讓自己在困境中越陷越深。

條理清晰,善做筆記

優等生往往一邊聽課一邊記重點,不是事無巨細全盤記錄,特別善於記下老師補充的東西,課本上沒有的東西,特別是思維方法更是認真記錄。老師在課堂上強調的重點,在他的筆記本里都應該找到。有位尖子生在自己筆記中間畫一條線,一邊記老師的重點,一邊寫課文里的注釋,復習一舉兩得。能及時整理自己平時細心積累的筆記本和錯題集,特別注意讓知識系統化,積極思考能解決什麼問題。

Ⅶ 命令進入ftp後,怎麼更換目錄

自己親自測試了一下,在FTP狀態下,與DOS命令通用 你可以用 CD 更換目錄,DIR 查看目錄 PWD查看當前所在目錄

Ⅷ 更改ftp根目錄查看方式

方法和詳細的操作步驟如下:

1、首先,打開ie瀏覽器,點擊「設置」選項中的「Internet 選項」,如下圖所示。

linux ftp 下怎麼把默認路徑改成自己的

1 比較一下倆個目錄的許可權: ls -ld /var/ftp 和 ls -ld /ftp/ff
2 關閉selinux

熱點內容
域名怎麼配置成不用埠訪問 發布:2024-10-27 14:18:11 瀏覽:724
水密碼嘭嘭水潤禮盒有什麼 發布:2024-10-27 14:18:00 瀏覽:85
安卓微信表情文件夾 發布:2024-10-27 14:11:06 瀏覽:229
寶座什麼配置好 發布:2024-10-27 14:03:34 瀏覽:590
android長按復制 發布:2024-10-27 14:03:32 瀏覽:529
cadlinux 發布:2024-10-27 14:02:53 瀏覽:755
賺賺客腳本 發布:2024-10-27 14:02:01 瀏覽:981
ln的演算法 發布:2024-10-27 13:52:19 瀏覽:933
c語言無輸入 發布:2024-10-27 13:33:26 瀏覽:462
箱變里邊主要由哪些配置 發布:2024-10-27 13:28:55 瀏覽:471