导航:首页 > 版本升级 > 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文件夹相关的资料

热点内容
穿越民国写小说养家 浏览:790
韩国女钢琴老师和男孩 浏览:138
申请id代码什么意思啊 浏览:483
韩国小孩子和大人电影 浏览:472
台湾电影中字未删减版 浏览:996
庆余年无删节版全文下载 浏览:536
衰鬼撬墙脚女主角 浏览:671
英语影视APP 浏览:235
韩国伦理片手臂有纹身的男主角 浏览:85
迷你编程森林冒险最后一关如何过 浏览:427
合肥小学生哪里学编程好 浏览:465
985大学生穿越大唐小说 浏览:656
长生电影 浏览:693
道txt下载 浏览:584
qq快传收到的app怎么安装啊 浏览:648
男主角身体有电的国产电影 浏览:370
免费看会员电影网址 浏览:440
蓝桥杯编程题在哪里编写 浏览:525
韩国电影女的美容店 浏览:912

友情链接