用ftp实现大文件上传
2007-07-10 19:58
225 查看
用asp.net上传文件时,对大文件的处理总会不尽于人意,虽然从理论上讲,可以传输很大的文件(100M以上),但在实际使用中会出现各种问题.因此,基于B/S架构的大文件上传还是用FTP为好。
用FTP手工上传文件没有什么可以说的,但我们往往需要通过程序来控制这一过程,即通过asp.net来实现这一目的.如果FTP软件具备可二次开发的接口就好了.经典的cuteftp pro就具有这样的功能。
安装完cuteftp pro 7后,会生成一个文件叫ftpte(FTP传输引擎),ftpte提供了很多属性和方法,能够方便地通过编程来实现大文件的上传,包括文件过滤、目录和文件检测、文件删除、改名、传输启动和停止以及状态查看等等。
下面是实例:
连接FTP服务器:
Set MySite = CreateObject("CuteFTPPro.TEConnection")
MySite.Protocol = "FTP"
MySite.Host = "ftp.cuteftp.net"
MySite.Login = "username"
MySite.Password = "password"
MySite.Connect
上传文件:
Set MySite = CreateObject("CuteFTPPro.TEConnection")
‘Specify user, pass, host, and connect as normal...
MySite.Connect ‘Recommended: call connect first
MySite.RemoteFolder = "Temp"
MySite.LocalFolder = "C:\123"
‘using relative path, all files in folder 123 are uploaded to the folder Temp off the current folder on the server.
MySite.Upload "*.*"
下载文件:
Set MySite = CreateObject("CuteFTPPro.TEConnection")
‘Specify user, pass, host, and connect as normal...
MySite.Connect ‘Recommended: call connect first
‘next line changes to a predetermined folder so you can use a relative path in the download method
MySite.RemoteFolder = "/c:/Inetpub/ftproot/Temp/Temp/"
MsgBox (MySite.RemoteFolder) ’display current remote folder
MySite.Download "agent.ini", "c:\temp\agent1.ini"
’now verify downloaded ok
If CBool(MySite.LocalExists ("c:\temp\agent1.ini")) Then
MsgBox "File downloaded OK."
End If
从实验的情况看,ftpte在C/S模式下能很好的支持各项功能,在B/S模式下会找不到组件,可能与没有注册有关。
通过利用ftpte,可能编程实现远程文件定时或不定时同步等诸多功能,从而实现非手工方式的文件传输。
用FTP手工上传文件没有什么可以说的,但我们往往需要通过程序来控制这一过程,即通过asp.net来实现这一目的.如果FTP软件具备可二次开发的接口就好了.经典的cuteftp pro就具有这样的功能。
安装完cuteftp pro 7后,会生成一个文件叫ftpte(FTP传输引擎),ftpte提供了很多属性和方法,能够方便地通过编程来实现大文件的上传,包括文件过滤、目录和文件检测、文件删除、改名、传输启动和停止以及状态查看等等。
下面是实例:
连接FTP服务器:
Set MySite = CreateObject("CuteFTPPro.TEConnection")
MySite.Protocol = "FTP"
MySite.Host = "ftp.cuteftp.net"
MySite.Login = "username"
MySite.Password = "password"
MySite.Connect
上传文件:
Set MySite = CreateObject("CuteFTPPro.TEConnection")
‘Specify user, pass, host, and connect as normal...
MySite.Connect ‘Recommended: call connect first
MySite.RemoteFolder = "Temp"
MySite.LocalFolder = "C:\123"
‘using relative path, all files in folder 123 are uploaded to the folder Temp off the current folder on the server.
MySite.Upload "*.*"
下载文件:
Set MySite = CreateObject("CuteFTPPro.TEConnection")
‘Specify user, pass, host, and connect as normal...
MySite.Connect ‘Recommended: call connect first
‘next line changes to a predetermined folder so you can use a relative path in the download method
MySite.RemoteFolder = "/c:/Inetpub/ftproot/Temp/Temp/"
MsgBox (MySite.RemoteFolder) ’display current remote folder
MySite.Download "agent.ini", "c:\temp\agent1.ini"
’now verify downloaded ok
If CBool(MySite.LocalExists ("c:\temp\agent1.ini")) Then
MsgBox "File downloaded OK."
End If
从实验的情况看,ftpte在C/S模式下能很好的支持各项功能,在B/S模式下会找不到组件,可能与没有注册有关。
通过利用ftpte,可能编程实现远程文件定时或不定时同步等诸多功能,从而实现非手工方式的文件传输。
相关文章推荐
- CentOS中使用Shell脚本实现每天自动备份网站文件和数据库并上传到FTP中(转)
- Java FTP 实现跨服务器文件上传下载
- java实现FTP文件上传与文件下载
- 基于Apache FTP实现的文件上传下载工具
- JAVA中使用FTPClient实现文件上传下载
- java实现ftp文件的上传与下载
- Java实现FTP与SFTP文件上传
- [转]文件传输协议(FTP)操作(上传,下载,新建,删除,FTP间传送文件等)实现汇总1
- Java实现ftp上传文件、文件夹
- java实现把文件上传至ftp服务器
- Java实现FTP文件与文件夹的上传和下载
- shell脚本实现FTP自动上传文件
- 【C#网络编程系列】专题十一:实现一个基于FTP协议的程序—文件上传下载器
- 20160113006 asp.net实现ftp上传代码(解决大文件上传问题)
- Qt5.8用FTP实现文件上传和下载(带进度条)
- Windows下通过bat脚本实现自动上传文件到ftp服务器
- 实现FTP文件上传与下载
- 三步FTP实现PHP上传文件代码剖析
- 用DOS批处理实现FTP自动上传、下载、清理文件
- java web FTPClient 实现上传文件到指定服务器