導航:首頁 > 版本升級 > netweb上傳圖片到ftp文件夾

netweb上傳圖片到ftp文件夾

發布時間:2021-04-21 06:41:13

Ⅰ asp.net中將本地文件上傳到ftp,在本地調試一切正常,發布到IIS後上傳時總提示無法找到文件

是不是先把文件上傳到伺服器上 然後在傳到ftp上 上傳文件的後台方法是什麼樣的? 發布到IIS的文件夾需要設置文件夾許可權

Ⅱ ASP.NET 上傳文件夾到FTP,按本地目錄結構上傳到FTP

壓縮>>上傳>>解壓

Ⅲ asp.net中上傳文件到遠程FTP伺服器指定目錄下,求大神幫助,小弟不勝感激

private string ftpServerIP = "伺服器ip";//伺服器ip
private string ftpUserID = "ftp的用戶名";//用戶名
private string ftpPassword = "ftp的密碼";//密碼
//filename 為本地文件的絕對路徑
//serverDir為伺服器上的目錄
private void Upload(string filename,string serverDir)
{
FileInfo fileInf = new FileInfo(filename);

string uri = string.Format("ftp://{0}/{1}/{2}", ftpServerIP,serverDir,fileInf.Name);
FtpWebRequest reqFTP;

// 根據uri創建FtpWebRequest對象
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));

// ftp用戶名和密碼
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);

// 默認為true,連接不會被關閉
// 在一個命令之後被執行
reqFTP.KeepAlive = false;

// 指定執行什麼命令
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;

// 指定數據傳輸類型
reqFTP.UseBinary = true;

// 上傳文件時通知伺服器文件的大小
reqFTP.ContentLength = fileInf.Length;

// 緩沖大小設置為2kb
int buffLength = 2048;

byte[] buff = new byte[buffLength];
int contentLen;

// 打開一個文件流 (System.IO.FileStream) 去讀上傳的文件
FileStream fs = fileInf.OpenRead();
try
{
// 把上傳的文件寫入流
Stream strm = reqFTP.GetRequestStream();

// 每次讀文件流的2kb
contentLen = fs.Read(buff, 0, buffLength);

// 流內容沒有結束
while (contentLen != 0)
{
// 把內容從file stream 寫入 upload stream
strm.Write(buff, 0, contentLen);

contentLen = fs.Read(buff, 0, buffLength);
}

// 關閉兩個流
strm.Close();
fs.Close();
}
catch (Exception ex)
{
// MessageBox.Show(ex.Message, "Upload Error");
Response.Write("Upload Error:" + ex.Message);
}
}

調用方法
string filename = "D:\\test.txt"; //本地文件,需要上傳的文件
string serverDir = "img"; //上傳到伺服器的目錄,必須存在
Upload(filename,serverDir);

Ⅳ web方式連接FTP 能上傳文件嗎 能的話怎麼上傳

Web方式上傳文件到FTP伺服器的方法 http://xz8.2000y.net/mb/2/readnews.asp?newsid=95170

Ⅳ 用ASP.NET做一個文件上傳功能,前台同過HTML input file 控制項 將文件上傳到FTP 伺服器 ;

第一,客戶端是沒辦法完成遍歷本地文件夾的。用JS做這個操作不現實。
第二,你上傳,也是先傳到本地伺服器,再通過FTP的方式用程序傳到FTP伺服器上去。這是兩個步驟。

Ⅵ c#中上傳文件至FTP指定目錄方法

http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=ftplib&DownloadId=625356&FileTime=130055467917930000&Build=20988
//第三方開源控制項下載如上面連接,使用如下面示例代碼
using(FtpConnectionftp=newFtpConnection("ftpserver","username","password"))//登錄
{

ftp.Open();/*OpentheFTPconnection*/
ftp.Login();/**/

if(ftp.DirectoryExists("/incoming"))/*checkthatadirectoryexists*/
ftp.SetCurrentDirectory("/incoming");/*changecurrentdirectory*/

if(ftp.FileExists("/incoming/file.txt"))/*checkthatafileexists*/
ftp.GetFile("/incoming/file.txt",false);/*download/incoming/file.txtasfile.,overwriteifitexists*/

//dosomeprocessing

try
{
ftp.SetCurrentDirectory("/outgoing");
ftp.PutFile(@"c:localfile.txt","file.txt");/*uploadc:localfile..txt*/
}
catch(FtpExceptione)
{
Console.WriteLine(String.Format("FTPError:{0}{1}",e.ErrorCode,e.Message));
}

foreach(vardirinftp.GetDirectories("/incoming/processed"))
{
Console.WriteLine(dir.Name);
Console.WriteLine(dir.CreationTime);
foreach(varfileindir.GetFiles())
{
Console.WriteLine(file.Name);
Console.WriteLine(file.LastAccessTime);
}
}
}

Ⅶ c#做.net網站,怎麼將圖片上傳到伺服器指定文件夾下。急請大家回答。

你保存的時候 指定了物理路徑 這點肯定不行 需使用Server.MapPath('文件路徑') 採用相對路徑存儲

Ⅷ 做好的asp.net上傳到ftp

ASP.NET網站項目的整個目錄都要原封不動上傳,包括資料庫文件,目錄結構不能改變!!
這個復雜,不用考慮那麼多的。

Ⅸ C#.net 上傳文件到FTP

可以利用 C# FTP上傳類上傳

publicclassFtpWeb
{
stringftpServerIP;
stringftpRemotePath;
stringftpUserID;
stringftpPassword;
stringftpURI;

///<summary>
///連接FTP
///</summary>
///<paramname="FtpServerIP">FTP連接地址</param>
///<paramname="FtpRemotePath">指定FTP連接成功後的當前目錄,如果不指定即默認為根目錄</param>
///<paramname="FtpUserID">用戶名</param>
///<paramname="FtpPassword">密碼</param>
publicFtpWeb(stringFtpServerIP,stringFtpRemotePath,stringFtpUserID,stringFtpPassword)
{
ftpServerIP=FtpServerIP;
ftpRemotePath=FtpRemotePath;
ftpUserID=FtpUserID;
ftpPassword=FtpPassword;
ftpURI="ftp://"+ftpServerIP+"/"+ftpRemotePath+"/";
}

///<summary>
///上傳
///</summary>
///<paramname="filename"></param>
publicvoidUpload(stringfilename)
{
FileInfofileInf=newFileInfo(filename);
stringuri=ftpURI+fileInf.Name;
FtpWebRequestreqFTP;

reqFTP=(FtpWebRequest)FtpWebRequest.Create(newUri(uri));
reqFTP.Credentials=newNetworkCredential(ftpUserID,ftpPassword);
reqFTP.KeepAlive=false;
reqFTP.Method=WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary=true;
reqFTP.ContentLength=fileInf.Length;
intbuffLength=2048;
byte[]buff=newbyte[buffLength];
intcontentLen;
FileStreamfs=fileInf.OpenRead();
try
{
Streamstrm=reqFTP.GetRequestStream();
contentLen=fs.Read(buff,0,buffLength);
while(contentLen!=0)
{
strm.Write(buff,0,contentLen);
contentLen=fs.Read(buff,0,buffLength);
}
strm.Close();
fs.Close();
}
catch(Exceptionex)
{
Insert_Standard_ErrorLog.Insert("FtpWeb","UploadError-->"+ex.Message);
}
}
}

Ⅹ web頁面可以用ftp上傳文件嗎

可以的 你看看NeatUpload控制項

閱讀全文

與netweb上傳圖片到ftp文件夾相關的資料

熱點內容
狂怒余男迅雷下載 瀏覽:572
抓四人幫的電視劇叫什麼 瀏覽:374
男主角找到世界的盡頭是建模 瀏覽:724
藍牙為什麼能升級嗎 瀏覽:31
js缺少分號 瀏覽:93
江羊電影公司作品 瀏覽:43
怎麼樣在網站下載紅色警戒 瀏覽:775
免費看電影無vip 瀏覽:108
路由器手機怎麼重置密碼 瀏覽:990
小孩抗日 小說 瀏覽:655
國外小孩與小孩性 愛視頻 瀏覽:965
cad導入ug無效文件 瀏覽:760
如何使用小圖標查看文件 瀏覽:166
免費大全在線網站不卡 瀏覽:490
韓國電影健身房教練 瀏覽:942
金剛2免費完整版正片 瀏覽:477
女蛇妖的電影 瀏覽:640
蘋果手機清除文件垃圾的方法 瀏覽:689
騰訊視頻有哪些版本 瀏覽:405
用數據線微信文件怎麼轉電腦 瀏覽:262

友情鏈接