zoukankan      html  css  js  c++  java
  • 用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 
    上传文件: 


    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,可能编程实现远程文件定时或不定时同步等诸多功能,从而实现非手工方式的文件传输。
  • 相关阅读:
    两台Mysql数据库数据同步实现
    利用Python读取外部数据文件
    在Python应用中使用MongoDB
    使用python语言操作MongoDB
    windows下Graphviz安装及入门教程
    【Machine Learning】决策树案例:基于python的商品购买能力预测系统
    Python数据可视化-seaborn
    np.tile 函数使用
    Python机器学习库scikit-learn实践
    基于C#net4.5websocket客户端与服务端
  • 原文地址:https://www.cnblogs.com/jinzhao/p/813113.html
Copyright © 2011-2022 走看看