当前位置:首页 » 文件管理 » netftp文件上传

netftp文件上传

发布时间: 2025-04-15 00:41:41

㈠ C# ASP.net ftp上传功能本地编译没问题,网站发布后通过网址访问再用此功能报404错误

404 错误意味着链接指向的网页不存在,即原始网页的URL失效,这种情况经常会发生,很难避免,比如说:网页URL生成规则改变、网页文件更名或移动位置、导入链接拼写错误等,导致原来的URL地址无法访问;当Web 服务器接到类似请求时,会返回一个404 状态码,告诉浏览器要请求的资源并不存在。
导致这个错误的原因一般来说,有三种:

1、无法在所请求的端口上访问Web站点。

2、Web服务扩展锁定策略阻止本请求。

3、MIME映射策略阻止本请求。
解决办法:
1. 对于存在的网页内容由于路径改变而导致访问不了时,可在IIS 中定义404错误指向一个动态页面,在页面里面使用301永久重定向跳转到新的地址,此时服务器返回301状态码。

2、设置404指向一个设计好的html文件,
此时页面返回的404状态码。
idc提供商基本都提供404设置的功能,直接上传文件设置即可。在IIs中设置方法:打开IIS管理器-->点击要设置自定义404的网站的属性
-->点击自定义错误选项-->选中404页-->选中并打开编辑属性-->设置成 URL --> URL
里填写“/err404.html”-->按确定退出再把做好的err404.html
页面上传到网站根目录下。此处在“消息类型”中一定要选择“文件”或“默认值”,而不要选择“URL”,不然,将导致返回“200”状态码。

3、404指向一个动态页面,
比如error.asp,如果不在页面里面进行设置,仅仅是返回提示的HTML 代码,将导致页面返回200
状态码,这是不正确的,我们可以在显示完提示内容后,增加语句: Response.Status="404 Not Found"
,这样就保证页面返回404状态码。

4、Apache下设置404错误页面。为Apache Server设置404错误页面的方法很简单,只需在.htaccess 文件中加入如下内容即可,ErrorDocument 404 /notfound.php

㈡ FTP上传文件错误

150 opening ascii mode data connection for /bin/ls.
426 data connection closed, transfer aborted.

这种情况可能是你所在网络安装了防火墙(或代理),该防火墙(或代理)禁止来自远程的连接,426 data connection closed, transfer aborted表明了这一点。这时候你可以使用被动传输模式(pasv模式),来避免该限制,进行数据传输.
解决办法是在该ftp标签的站点设置中,设置为被动模式pasv模式.同样,如果前面有网友出现200 port command successful.
连不上的情况,也用上面方法

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 (#1)
error: connection timed out

这个表明对方未开机,也可能是对方不在你能访问的范围内。可能小区的服务器检修中。

4.

connecting to xxx.xxx.xxx.xxx port 21 (#1)
error: connection refused
这个一般表明对方已开机,但未开启ftp服务(没有开serv-u)
也可能为对方不提供在这个端口上的服务

5.

connecting to xxx.xxx.xxx.xxx, port 21 (#1)
connected. waiting for response.
disconnected from server.
connection attempt failed. waiting for retry...
出现这个信息实在是很倒霉,你极有可能把重试时间定的太短服务器封了你哟!

6.
connecting to xxx.xxx.xxx.xxx, port 21 (#1)
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.
传输已失败!
传输队列已完成
你的流量不够了,重新购买吧!

8.
connected. waiting for response.
220 serv-u ftp server v4.0 for winsock ready...
user user
421 too many users - please try again later.
说明当前你所属的下载组的下载人数已到上限,请过些时候再尝试,用Flashget等的下载工具不断尝试联接的人请讲尝试时间调大一点,否则会被服务器封闭一段时间的IP

9.
150 opening ascii mode data connection for /bin/ls.
426 data connection closed, transfer aborted.

这种情况可能是你所在网络安装了防火墙(或代理),该防火墙(或代理)禁止来自远程的连接,426 data connection closed, transfer aborted表明了这一点。这时候你可以使用被动传输模式(pasv模式),来避免该限制,进行数据传输.
解决办法是在该ftp标签的站点设置中,设置为被动模式pasv模式.同样,如果前面有网友出现200 port command successful.
连不上的情况,也用上面方法

Connecting to xxx.xxx.xxx.xxx, Port 21 (#1)
ERROR: Connection timed out
这个表明对方未开机,也可能是对方不在你能访问的范围内
-----------------------------------
Connecting to xxx.xxx.xxx.xxx Port 21 (#1)
ERROR: Connection refused
这个一般表明对方已开机,但未开启FTP服务(没有开Serv-U)
也可能为对方不提供在这个端口上的服务
-----------------------------------
Connecting to xxx.xxx.xxx.xxx, Port 21 (#1)
Connected. Waiting for response.
Disconnected from server.
Connection attempt failed. Waiting for retry...
出现这个信息实在是很倒霉,你极有可能被对方Ban了。
如果只是Ban几分钟or几小时or一天还好,不然只有和站长说说好话,让他给你解封吧。

-----------------------------------
110 Restart marker reply. In this case, the text is exact and not left to
the particular implementation; it must read: MARK yyyy = mmmm where yyyy is
User-process data stream marker, and mmmm server s equivalent marker (note
the spaces between markers and "=").
重新启动标志回应。这种情况下,信息是精确的并且不用特别的处理;可以这样看:标记 yyyy = mmm 中 yyyy是 用户进程数据流标记,mmmm是服务器端相应的标记(注意在标记和等号间的空格)
-----------------------------------
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.
服务不可用,控制连接关闭。这可能是对任何命令的回应,如果服务认为它必须关闭
421 Too many users - please try again later.
太多用户,那就过会再连
-----------------------------------
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.
一般来说是密码错误。
530 Sorry, no ANONYMOUS access allowed.
这个就是不许匿名登录
530 Not logged in, unauthorized IP address
这个有点麻烦,你的IP不在站长允许访问的IP范围内,只有和站长联系,让他把你的IP网段加入Allow Access列表里吧
530 Not logged in, only one(也有可能是two or three) session from same IP allowed at a time.
每个IP只能开一个(也有可能是two or three) 下载,就不要用多线程啦,小心Ban了你。
-----------------------------------
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开头--服务器问题

㈢ 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);
}
}
}

㈣ 如何汉化net2ftp

在\files_to_upload里面找到settings.inc.php,这个是配置文件,用记事本打开它,我们来进行简单的设置。找到
$net2ftp_settings["default_language"] = "en";(默认的语言英语,汉语版本有问题,不建议使用)
$net2ftp_settings["default_skin"] ; ; ; ;= "india";(皮肤,建议改成blue,因为这个皮肤做的很完美)
$net2ftp_settings["admin_username"] = "admin";(默认的管理员名称,可以修改)
$net2ftp_settings["admin_password"] = "";(默认为空,如果你要记录程序使用日志,添加密码即可)
$net2ftp_settings["max_upload_filesize"] ; ;= "2000000"; ; ;(文件最大上传大小,默认2M,根据需要修改)
$net2ftp_settings["use_database"] = "no"; (是否记录登陆日志,默认NO,可修改为YES,别忘了把create_tables.sql导入到你的MySQL里面)
// Enter your MySQL settings(这里的几个要在上面那个选项为YES时填写)
$net2ftp_settings["dbusername"] = "";用户名
$net2ftp_settings["dbpassword"] = "";密码
$net2ftp_settings["dbname"] ; ; ; ;= "";数据库
$net2ftp_settings["dbserver"] ; ;= "localhost"; 地址
$net2ftp_settings["max_consumption_ipaddress_dataTransfer"] = 20000000; // 每个IP每天最多传输文件字节$net2ftp_settings["max_consumption_ftpserver_dataTransfer"] =50000000; // 每个FTP服务器最多接受字节

㈤ VB.net连接FTP操作

MSDN上的,看看对你有没有帮助。GOOD LUCK!

Imports System.Net
Imports System.IO

Mole FtpSample

Sub Main(ByVal args() As String)
If args.Length = 0 OrElse args(0).Equals("/?") Then
DisplayUsage()
ElseIf args.Length = 1 Then
Download(args(0))
ElseIf args.Length = 2 Then
If args(0).Equals("/list") Then
List(args(1))
Else
Upload(args(0), args(1))
End If
Else
Console.WriteLine("Unrecognized argument.")
End If
End Sub

Private Sub DisplayUsage()
Console.WriteLine("USAGE:")
Console.WriteLine(" FtpSample [/? | <FTP download URL> | <local file>")
Console.WriteLine(" <FTP upload URL> | /list <FTP list URL>]")
Console.WriteLine()
Console.WriteLine("where")
Console.WriteLine(" FTP download URL URL of a file to download from an FTP server.")
Console.WriteLine(" FTP upload URL Location on a FTP server to upload a file to.")
Console.WriteLine(" FTP list URL Location on a FTP server to list the contents of.")
Console.WriteLine(" local file A local file to upload to an FTP server.")
Console.WriteLine()
Console.WriteLine(" Options:")
Console.WriteLine(" /? Display this help message.")
Console.WriteLine(" /list Specifies the list command.")
Console.WriteLine()
Console.WriteLine("EXAMPLES:")
Console.WriteLine(" Download a file FtpSample ftp://myserver/download.txt")
Console.WriteLine(" Upload a file FtpSample upload.txt ftp://myserver/upload.txt")
End Sub

Private Sub Download(ByVal downloadUrl As String)
Dim responseStream As Stream = Nothing
Dim fileStream As FileStream = Nothing
Dim reader As StreamReader = Nothing
Try
Dim downloadRequest As FtpWebRequest = _
WebRequest.Create(downloadUrl)
Dim downloadResponse As FtpWebResponse = _
downloadRequest.GetResponse()
responseStream = downloadResponse.GetResponseStream()

Dim fileName As String = _
Path.GetFileName(downloadRequest.RequestUri.AbsolutePath)

If fileName.Length = 0 Then
reader = New StreamReader(responseStream)
Console.WriteLine(reader.ReadToEnd())
Else
fileStream = File.Create(fileName)
Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = responseStream.Read(buffer, 0, buffer.Length)
If bytesRead = 0 Then
Exit While
End If
fileStream.Write(buffer, 0, bytesRead)
End While
End If
Console.WriteLine("Download complete.")
Catch ex As UriFormatException
Console.WriteLine(ex.Message)
Catch ex As WebException
Console.WriteLine(ex.Message)
Catch ex As IOException
Console.WriteLine(ex.Message)
Finally
If reader IsNot Nothing Then
reader.Close()
ElseIf responseStream IsNot Nothing Then
responseStream.Close()
End If
If fileStream IsNot Nothing Then
fileStream.Close()
End If
End Try
End Sub

Private Sub Upload(ByVal fileName As String, ByVal uploadUrl As String)
Dim requestStream As Stream = Nothing
Dim fileStream As FileStream = Nothing
Dim uploadResponse As FtpWebResponse = Nothing
Try
Dim uploadRequest As FtpWebRequest = WebRequest.Create(uploadUrl)
uploadRequest.Method = WebRequestMethods.Ftp.UploadFile

' UploadFile is not supported through an Http proxy
' so we disable the proxy for this request.
uploadRequest.Proxy = Nothing

requestStream = uploadRequest.GetRequestStream()
fileStream = File.Open(fileName, FileMode.Open)

Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = fileStream.Read(buffer, 0, buffer.Length)
If bytesRead = 0 Then
Exit While
End If
requestStream.Write(buffer, 0, bytesRead)
End While

' The request stream must be closed before getting the response.
requestStream.Close()

uploadResponse = uploadRequest.GetResponse()
Console.WriteLine("Upload complete.")
Catch ex As UriFormatException
Console.WriteLine(ex.Message)
Catch ex As IOException
Console.WriteLine(ex.Message)
Catch ex As WebException
Console.WriteLine(ex.Message)
Finally
If uploadResponse IsNot Nothing Then
uploadResponse.Close()
End If
If fileStream IsNot Nothing Then
fileStream.Close()
End If
If requestStream IsNot Nothing Then
requestStream.Close()
End If
End Try
End Sub

Private Sub List(ByVal listUrl As String)
Dim reader As StreamReader = Nothing
Try
Dim listRequest As FtpWebRequest = WebRequest.Create(listUrl)
listRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails
Dim listResponse As FtpWebResponse = listRequest.GetResponse()
reader = New StreamReader(listResponse.GetResponseStream())
Console.WriteLine(reader.ReadToEnd())
Console.WriteLine("List complete.")
Catch ex As UriFormatException
Console.WriteLine(ex.Message)
Catch ex As WebException
Console.WriteLine(ex.Message)
Finally
If reader IsNot Nothing Then
reader.Close()
End If
End Try
End Sub

End Mole

可以通过设置 Credentials 属性来指定用于连接服务器的凭据,也可以将它们包含在传递给 Create 方法的 URI 的 UserInfo 部分中。

从 FTP 服务器下载文件时,如果命令成功,所请求的文件的内容即在响应对象的流中。通过调用 GetResponseStream 方法,可以访问此流。

如果使用 FtpWebRequest 对象向服务器上载文件,则必须将文件内容写入请求流,请求流是通过调用 GetRequestStream 方法或其异步对应方法(BeginGetRequestStream 和 EndGetRequestStream 方法)获取的。必须写入流并在发送请求之前关闭该流。

请求是通过调用 GetResponse 方法或其异步对应方法(BeginGetResponse 和 EndGetResponse 方法)发送到服务器的。请求的操作完成时,会返回一个 FtpWebResponse 对象。FtpWebResponse 对象提供操作的状态以及从服务器下载的所有数据。

㈥ 高手求助sun.net.ftp.FtpClient下载中文名文件问题。

如果文件名是中文的话,报200、227、501错误,就检查服务器设置的OPTS,UTF8,是否为逗禁用命令地。全局属性第三个是否关闭。

ftp上传文件时,必须使用英文字符或数据的文件名才能上传,或者是两个字的汉字才能上传到服务器的话:
1、进入ServerU管理端界面,点击逗服务器限制和设置地分类功能按钮,

2、在ServerU服务器限制和设置界面,选择逗FTP设置地页签,点击窗口下面的逗全局设置地按钮。

3、在打开的逗FTP命令属性地界面,去掉最后一行的勾选,即不要勾选地对所有已收发的路径和文件名使用UTF-8编码逗。

4、选择逗FTP设置地页签,禁用地OPTS UTF8 逗,
完成上面的两处改变后,无法上传中文名称的文件的问题应该已经解决了。

热点内容
cf服务器如何加子弹 发布:2025-04-16 06:39:08 浏览:936
如何修改wf密码名称 发布:2025-04-16 06:31:06 浏览:199
吃鸡安卓主播用什么投屏 发布:2025-04-16 06:29:33 浏览:820
python元素是否存在 发布:2025-04-16 06:16:39 浏览:329
优酷上传侵权视频 发布:2025-04-16 06:15:03 浏览:50
现代伊兰特7代有哪些配置 发布:2025-04-16 06:12:26 浏览:650
啪啪访问视频 发布:2025-04-16 05:57:35 浏览:859
电信烽火盒子设置密码是多少 发布:2025-04-16 05:56:48 浏览:408
sqldatetime 发布:2025-04-16 05:51:08 浏览:893
javaweb项目源码下载 发布:2025-04-16 05:17:31 浏览:880