可上传下载控件(转)

这是控件的源程序:
工程名:MY
控件名:TESTFTP

Dim FileName As String
Dim connect As Boolean


Private Sub CmdCd_Click()

Call Link
'Inet1.Execute , "cd c2000"
connect = True

End Sub

Private Sub CmdList_Click()

If connect = True Then
Inet1.Execute , "LS"
Else
Label1.Caption = "please click connect first!"
End If

End Sub


Private Sub Combo1_Click()

FileName = Combo1.Text 'file name of download file

End Sub

Private Sub CmdDown_Click()

Dim FileLast As String 'last name of file
Dim SaveFileName As String 'file name in ftpserver
Call Link

If FileName = "" Then
Label1.Caption = "please select file to download!"
Else
FileLast = ""
For i = 1 To Len(FileName)
If Mid(FileName, i, 1) <> "." Then
FileLast = FileLast + Mid(FileName, i, 1)
Else
FileLast = ""
End If
Next
REDO: CommonDialog1.ShowSave

If InStr(1, CommonDialog1.FileName, " ", 1) > 0 Then
Label1.Caption = "The file can't include space!"
MyVar = MsgBox("Redo it?", 65, "Download file")
If MyVar = "1" Then
GoTo REDO:
Else
GoTo NODO:
End If
End If

SaveFileName = CommonDialog1.FileName & "." & FileLast
Inet1.Execute , "GET " & FileName & " " & SaveFileName
End If
NODO:

End Sub

Private Sub CmdUpload_Click()

Dim SaveFileName As String
Dim UpFileName As String 'file name of upload file include path
Dim MyVar
SaveFileName = ""
Call Link

REDO:CommonDialog1.ShowOpen

If InStr(1, CommonDialog1.FileName, " ", 1) > 0 Then
MsgBox "The file can't include space!"
MyVar = MsgBox("Redo it?", 65, "Upload file")
If MyVar = "1" Then
GoTo REDO:
Else
GoTo NODO:
End If
End If

UpFileName = CommonDialog1.FileName
'MsgBox UpFileName

For i = 1 To Len(UpFileName)
If Mid(UpFileName, i, 1) <> "" Then
SaveFileName = SaveFileName + Mid(UpFileName, i, 1)
Else
SaveFileName = ""
End If
Next

If SaveFileName = "" Then
Label1.Caption = "no file!"
Else
Inet1.Execute , "PUT " & UpFileName & " " & SaveFileName
End If
NODO:

End Sub




Private Sub Inet1_StateChanged(ByVal State As Integer)

Select Case State
Case 1
Label1.Caption = "正在查询所指定的主机的 IP 地址"
Case 2
Label1.Caption = "成功地找到所指定的主机的 IP 地址。"
Case 3
Label1.Caption = "正在与主机连接"
Case 4
Label1.Caption = "连接成功"
Case 5
Label1.Caption = "正在向主机发送请求"
Case 6
Label1.Caption = "发送请求已成功"
Case 7
Label1.Caption = "正在接收主机的响应"
Case 8
Label1.Caption = "成功地接收到主机的响应"
Case 11
Label1.Caption = "出现了错误。"
Case 12
Label1.Caption = "该请求已经完成,并且所有数据均已接收到"
Dim vtData As Variant '数据变量。
Dim strData As String: strData = ""
Dim bDone As Boolean: bDone = False
Dim LenStr As Integer 'the length of liststr
Dim ListStr As String 'get string from ftpserver
Dim ItemStr As String 'the item file name of liststr
Dim i As Integer
'取得第一块。
vtData = Inet1.GetChunk(1024, icString)
DoEvents
Do While Not bDone
strData = strData & vtData
DoEvents
'取得下一块。
vtData = Inet1.GetChunk(1024, icString)
If Len(vtData) = 0 Then
bDone = True
End If
Loop
Combo1.Clear
ListStr = strData
LenStr = Len(ListStr)
For i = 1 To LenStr
If Mid(ListStr, i, 1) <> Chr(13) Then
ItemStr = ItemStr + Mid(ListStr, i, 1)
Else
If Left(ItemStr, 1) = Chr(10) Then
ItemStr = Mid(ItemStr, 2)
End If
If Right(ItemStr, 1) <> "/" Then
Combo1.AddItem ItemStr
End If
ItemStr = ""
End If
Next
End Select

End Sub


Private Sub Link()

With Inet1
.AccessType = 0
.URL = "http://10.132.16.135"
.UserName = "root"
.Password = "super"
.Protocol = icFTP
.RequestTimeout = 10
End With

End Sub


Private Sub UserControl_Terminate()

Inet1.Execute , "close"

End Sub

说明:有关主机名称,用户及口令等要改为你实际使用的。
生成OCX文件后再注册一下。
在网页里的调用:



content="text/html; charset=gb_2312-80">

我的控件




classid="clsid:282433B5-27DA-11D4-BE9B-0050BADA248E"
align="baseline" border="0" width="320" height="240">




试用结果应该不错的。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7178747/viewspace-161985/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7178747/viewspace-161985/

新颖网络上传插件(StorageWebPlug)是一个支持超大文件(2GB,可扩展)上传的COM控件, 具备断点续,文件MD5验证,大大提高上传效率、节省带宽,有详细的上传进度显示,支持多种脚本语言,欢迎下载体验。免费提供JavaScript SDK包。 产品特点: 1、文件上传使用增强的FTP协议,用户使用浏览器就可以上传超大文件到服务器(支持上传超过1G的文件)。 2、支持断点续,系统智能续上传的文件,续操作更简单,更方便,更快捷。 3、支持文件批量上传, 一次可以上传多个文件. 上传时有详细的状态显示(包括单个文件进度,整体进度,输速率,剩余时间等)。 4、新颖网络免费提供JavaScript SDK包。通过新颖网络提供的封装好的JavaScript类库用户可以快速的与现有系统整合。 5、StorageWebPlug提供完善的接口帮助文档,开发文档。开发人员可以动态设置上传保存路径, 设置允许扩展名, 允许最大大小等,可自定义强。 6、支持各种代理(HTTP, Socket4, Socket5等)。 7、组件采用多线程机制来保证上传效率。 8、支持批量文件上传, 用户可以一次性上传批量文件. 客户端可以绑定HTML表单变量, 服务端并可以接收表单变量 9、服务端文件保存路径可以随意指定,服务端文件保存路径可以灵活变化。保存路径支持网络路径。 10、为提高安全性,服务端组件可以指定用户权限 11、可以限制上传单个文件大小, 控制上传带宽上限, 允许文件扩展名, 拒绝文件扩展名等 12、上传数据时会根据网络状况来控制数据包大小, 避免网络堵塞 13、控件采用ATL编写, cab包只有59KB, 用56k的modem下载不会超过12秒 14、服务端支持Windows 2000 Server/Windows 2003 Server/Windows NT/Windows XP/Unix/Linux等操作系统 15、通过新颖网络业界领先的设计水平打造的操作界面可以帮助您的系统产品获得更高的品质。 产品介绍:http://www.ncmem.com/service_storagewebplug.aspx 下载地址:http://www.ncmem.com/download.aspx
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值