當前位置:首頁 » 文件傳輸 » ftp怎麼轉移伺服器
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

ftp怎麼轉移伺服器

發布時間: 2022-08-10 18:35:27

『壹』 如何使用FTP上傳文件到伺服器

使用FTP上傳文件到伺服器方法如下:

工具:FileZilla

1、雙擊FileZilla。彈出如下的工作界面

『貳』 請教:FTP伺服器轉移

您在伺服器中安裝一下FTP服務端軟體。
在本地電腦上安裝一下FTP客戶端,客戶端通過服務端的IP、FTP用戶名、密碼就可以轉移數據了。
海騰數據張毅龍為您回答,希望可以幫到您。

『叄』 C# 將FTP文件轉移到另一個FTP伺服器上如何實現

C# ftp上傳ftp
/// <summary>
/// 上傳文件
/// </summary> /
// <param name="fileinfo">需要上傳的文件</param>
/// <param name="targetDir">目標路徑</param>
/// <param name="hostname">ftp地址</param> /
// <param name="username">ftp用戶名</param> /
// <param name="password">ftp密碼</param>
public static void UploadFile(FileInfo fileinfo, string targetDir, string hostname, string username, string password)
{ //1. check target
string target;
if (targetDir.Trim() == "")
{ return; }
target = Guid.NewGuid().ToString();
//使用臨時文件名
string URI = "FTP://" + hostname + "/" + targetDir + "/" + target;
///WebClient webcl = new WebClient();
System.Net.FtpWebRequest ftp = GetRequest(URI, username, password);
//設置FTP命令 設置所要執行的FTP命令,
//ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;//假設此處為顯示指定路徑下的文件列表
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
//指定文件傳輸的數據類型
ftp.UseBinary = true;
ftp.UsePassive = true; //告訴ftp文件大小
ftp.ContentLength = fileinfo.Length;
//緩沖大小設置為2KB
const int BufferSize = 2048;
byte[] content = new byte[BufferSize - 1 + 1];
int dataRead; //打開一個文件流 (System.IO.FileStream) 去讀上傳的文件
using (FileStream fs = fileinfo.OpenRead())
{
try { //把上傳的文件寫入流
using (Stream rs = ftp.GetRequestStream())
{ do
{ //每次讀文件流的2KB
dataRead = fs.Read(content, 0, BufferSize); rs.Write(content, 0, dataRead); }
while (!(dataRead < BufferSize)); rs.Close(); } }
catch (Exception ex) { } finally { fs.Close(); } }
ftp = null; //設置FTP命令
ftp = GetRequest(URI, username, password);
ftp.Method = System.Net.WebRequestMethods.Ftp.Rename; //改名
ftp.RenameTo = fileinfo.Name; try { ftp.GetResponse(); }
catch (Exception ex)
{
ftp = GetRequest(URI, username, password); ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile; //刪除
ftp.GetResponse(); throw ex; } finally
{
//fileinfo.Delete(); } // 可以記錄一個日誌 "上傳" + fileinfo.FullName + "上傳到" + "FTP://" + hostname + "/" + targetDir + "/" + fileinfo.Name + "成功." );
ftp = null;
#region
/***** *FtpWebResponse * ****/ //FtpWebResponse ftpWebResponse = (FtpWebResponse)ftp.GetResponse();
#endregion
}
/// <summary>
/// 下載文件
/// </summary>
/// <param name="localDir">下載至本地路徑</param>
/// <param name="FtpDir">ftp目標文件路徑</param>
/// <param name="FtpFile">從ftp要下載的文件名</param>
/// <param name="hostname">ftp地址即IP</param>
/// <param name="username">ftp用戶名</param>
/// <param name="password">ftp密碼</param>
public static void DownloadFile(string localDir, string FtpDir, string FtpFile, string hostname, string username, string password)
{
string URI = "FTP://" + hostname + "/" + FtpDir + "/" + FtpFile;
string tmpname = Guid.NewGuid().ToString();
string localfile = localDir + @"\" + tmpname;

System.Net.FtpWebRequest ftp = GetRequest(URI, username, password);
ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile;
ftp.UseBinary = true;
ftp.UsePassive = false;

using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
//loop to read & write to file
using (FileStream fs = new FileStream(localfile, FileMode.CreateNew))
{
try
{
byte[] buffer = new byte[2048];
int read = 0;
do
{
read = responseStream.Read(buffer, 0, buffer.Length);
fs.Write(buffer, 0, read);
} while (!(read == 0));
responseStream.Close();
fs.Flush();
fs.Close();
}
catch (Exception)
{
//catch error and delete file only partially downloaded
fs.Close();
//delete target file as it's incomplete
File.Delete(localfile);
throw;
}
}

responseStream.Close();
}

response.Close();
}

try
{
File.Delete(localDir + @"\" + FtpFile);
File.Move(localfile, localDir + @"\" + FtpFile);

ftp = null;
ftp = GetRequest(URI, username, password);
ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile;
ftp.GetResponse();

}
catch (Exception ex)
{
File.Delete(localfile);
throw ex;
}

// 記錄日誌 "從" + URI.ToString() + "下載到" + localDir + @"\" + FtpFile + "成功." );
ftp = null;
}

/// <summary>
/// 搜索遠程文件
/// </summary>
/// <param name="targetDir"></param>
/// <param name="hostname"></param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <param name="SearchPattern"></param>
/// <returns></returns>
public static List<string> ListDirectory(string targetDir, string hostname, string username, string password, string SearchPattern)
{
List<string> result = new List<string>();
try
{
string URI = "FTP://" + hostname + "/" + targetDir + "/" + SearchPattern;

System.Net.FtpWebRequest ftp = GetRequest(URI, username, password);
ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectory;
ftp.UsePassive = true;
ftp.UseBinary = true;

string str = GetStringResponse(ftp);
str = str.Replace("\r\n", "\r").TrimEnd('\r');
str = str.Replace("\n", "\r");
if (str != string.Empty)
result.AddRange(str.Split('\r'));

return result;
}
catch { }
return null;
}

private static string GetStringResponse(FtpWebRequest ftp)
{
//Get the result, streaming to a string
string result = "";
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
long size = response.ContentLength;
using (Stream datastream = response.GetResponseStream())
{
using (StreamReader sr = new StreamReader(datastream, System.Text.Encoding.Default))
{
result = sr.ReadToEnd();
sr.Close();
}

datastream.Close();
}

response.Close();
}

return result;
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;

/// <summary>
/// 向Ftp伺服器上傳文件並創建和本地相同的目錄結構
/// 遍歷目錄和子目錄的文件
/// </summary>
/// <param name="file"></param>
private void GetFileSystemInfos(FileSystemInfo file)
{
string getDirecName=file.Name;
if (!ftpIsExistsFile(getDirecName, "192.168.0.172", "Anonymous", "") && file.Name.Equals(FileName))
{
MakeDir(getDirecName, "192.168.0.172", "Anonymous", "");
}
if (!file.Exists) return;
DirectoryInfo dire = file as DirectoryInfo;
if (dire == null) return;
FileSystemInfo[] files = dire.GetFileSystemInfos();

for (int i = 0; i < files.Length; i++)
{
FileInfo fi = files[i] as FileInfo;
if (fi != null)
{
DirectoryInfo DirecObj=fi.Directory;
string DireObjName = DirecObj.Name;
if (FileName.Equals(DireObjName))
{
UploadFile(fi, DireObjName, "192.168.0.172", "Anonymous", "");
}
else
{
Match m = Regex.Match(files[i].FullName, FileName + "+.*" + DireObjName);
//UploadFile(fi, FileName+"/"+DireObjName, "192.168.0.172", "Anonymous", "");
UploadFile(fi, m.ToString(), "192.168.0.172", "Anonymous", "");
}
}
else
{
string[] ArrayStr = files[i].FullName.Split('\\');
string finame=files[i].Name;
Match m=Regex.Match(files[i].FullName,FileName+"+.*"+finame);
//MakeDir(ArrayStr[ArrayStr.Length - 2].ToString() + "/" + finame, "192.168.0.172", "Anonymous", "");
MakeDir(m.ToString(), "192.168.0.172", "Anonymous", "");
GetFileSystemInfos(files[i]);
}
}
}

/// <summary>
/// 判斷ftp伺服器上該目錄是否存在
/// </summary>
/// <param name="dirName"></param>
/// <param name="ftpHostIP"></param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
private bool ftpIsExistsFile(string dirName, string ftpHostIP, string username, string password)
{
bool flag = true;
try
{
string uri = "ftp://" + ftpHostIP + "/" + dirName;
System.Net.FtpWebRequest ftp = GetRequest(uri, username, password);
ftp.Method = WebRequestMethods.Ftp.ListDirectory;

FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
response.Close();
}
catch (Exception )
{
flag = false;
}
return flag;
}

『肆』 怎麼用FTP把文件上傳到伺服器

使用伺服器的 ip地址和賬號信息,用ftp軟體就可以用來上傳文件了。

和別人共用伺服器時採用的方法。可以把對方的許可權限制到某個文件夾裡面,他只能在這里上傳下載文件,對於伺服器安全、許可權都有保障。

『伍』 java如何實現將FTP文件轉移到另一個FTP伺服器上

你有FTPClient就比較好辦,假如你的兩台FTP伺服器分別為fs1和fs2

在本地開發代碼思路如下:

  1. 通過FTPClient連接上fs1,然後下載(可以循環批量下載)到本地伺服器,保存到一個臨時目錄。

  2. 下載完成後,FTPClient斷開與fs1的連接,記得必須logout。

  3. 本地伺服器通過FileInputStream將剛下載到臨時目錄的文件讀進來,得到一個List<File>集合。

  4. 通過FTPClient連接上fs2,循環List<File>集合,將文件上傳至fs2的特定目錄,然後清空臨時目錄,上傳完畢後,斷開fs2的連接,同樣必須logout。

『陸』 如何將數據轉移至新的伺服器

1. 先登陸舊伺服器上的LUM,在「清理垃圾」中將mysql和postgres的日誌清除干凈2. 將/home/ftp, /home/mysql_data, /home/pgsql_data, /home/lum_safe_files目錄打包,文件名為my_data.tar.gz(如果有多個FTP主目錄,需要將所有FTP主目錄都打包):cd /home; tar -zcvf my_data.tar.gz ftp mysql_data pgsql_data lum_safe_files3. 在新伺服器上安裝好LuManager,但需要注意的一點就是,新伺服器的上資料庫版本需要與舊版本的一致,如舊版本的mysql版本為5.1.59,新伺服器上的mysql也必須是5.1,可以是5.1.59,也可以是5.1.61,但不要使用mysql5.5.X4. 在新伺服器上執行lu-stop,停止lu服務5. 將新伺服器上的/home/ftp, /home/mysql_data, /home/pgsql_data, /home/lum_safe_files目錄重命名mv /home/ftp /home/ftp.oldmv /home/mysql_data /home/mysql_data.oldmv /home/pgsql_data /home/pgsql_data.oldmv /home/lum_safe_files /home/lum_safe_files.old6. 將舊伺服器上的備份文件my_data.tar.gz轉移到新伺服器上的/home目錄下,然後解壓tar -zxvf my_data.tar.gz7. 在新伺服器上執行lu-start,啟動lu服務,然後再用舊伺服器上的帳號登陸LUM便可

『柒』 如何把建立在自己電腦上的ftp伺服器轉移到另一台電腦

在你對應的
/etc/vsftpd/vsftpd_user_conf 目錄下 ,把對應賬號的
local_root=/home/exchangeftp/edmp/ftpdata/34400001
local_root這個路徑改成另一個伺服器的 。

『捌』 如何從一個ftp的文件轉移到另一個ftp

只能重新上傳了。你是想遷移ftp伺服器嗎?用愛米雲共享網盤的,遷移伺服器非常方便,功能完全可以代替ftp,比ftp還好用

『玖』 如何直接把數據從一個ftp伺服器上直接復制到另一個ftp伺服器上,而不需要先下載然後上傳

用Flashfxp這個軟體,可以同時開啟2個FTP網站,你就可以將數據從這個轉到那一個上面去,不過前提是你自己機器上這個程序不能關。

『拾』 怎樣FTP 把a伺服器空間轉到B伺服器空間

建議你用8UFTP,這個軟體是國產簡體中文版的,免費的。目前FTP工具市場上體積相對最小。涵蓋其它FTP工具功能,支持多線程上傳,同時支持直接上傳壓縮包,可在空間上直接壓縮上傳,也可上傳後在空間上直接解壓。

8UFTP工具包括8UFTP客戶端工具和8UFTP智能擴展伺服器端工具。

1、同時安裝8UFTP客戶端和8UFTP智能擴展伺服器端工具,結合實現在線解壓縮功能。
2、8UFTP客戶支持目前市場上所有FTP服務端
3、8UFTP智能擴展伺服器端配合客戶端工具實現在線解壓縮功能,當前僅支持Serv-U。