|
|
|
![]() |
|
| 学院首页 | 备案专题 | 网络创业 | 网上开店 | 网页设计 | 图形图像 | 网络安全 | 网上支付 | 网站建设 | 多媒体 | 操作系统 | 办公软件 | 数据库 | 网络编程 | 网络原理 | 电脑应用 | 上网冲浪 | 专题 | 留言本 | 搜索 |
关于大文件上传的FTP解决方案
用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 上传文件:
‘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 "*.*" 下载文件:
‘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,可能编程实现远程文件定时或不定时同步等诸多功能,从而实现非手工方式的文件传输。 责任编辑:cxm
|
|
| 易耐特™智能建站平台-中小企业上网首选品牌 |
| 关于我们 | 版权声明 | 广告服务 | 联系我们 | 诚聘英才 | 友情链接 | 网站公告 | 留言本 |