如何用VB的api实现FTP文件上传?有人知道吗?只要FTP的上传功能,不要下载功能。要用API编的。有人知道吗?
解决方案 »
- text文本框在运行时如何根据输入文字行数的多少动态改变其Height属性
- 请问:哪里有InstallShield AdminStudio 6.0 企业注册版可以下载的地址?
- 如何判断一个数组是一维数组还是二维数组??
- 怎样让图片在调用时放大或缩小
- 问个在全局使用数组的小白问题??
- ★★★★怪异的变量定义问题,请有经验的看看吧,没折啦.★★★★急等!!!!!!
- 人有三急,其中一急!form1控制form2的问题?
- 大家来帮帮忙,出点主意!(来者有分)
- 对于大家的评价我不想解释!过几天我来结贴!!
- VB语法
- 画非纸质流程图有啥绝招??
- vb程序在客户机上连接sql server不存在或访问被拒绝
success = ftp.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
MsgBox ftp.LastErrorText
Exit Sub
End Ifftp.Hostname = "ftp.chilkatsoft.com"
ftp.Username = "****"
ftp.Password = "****"' The default data transfer mode is "Active" as opposed to "Passive".' Connect and login to the FTP server.
success = ftp.Connect()
If (success <> 1) Then
MsgBox ftp.LastErrorText
Exit Sub
End If' Change to the remote directory where the file will be uploaded.
success = ftp.ChangeRemoteDir("junk")
If (success <> 1) Then
MsgBox ftp.LastErrorText
Exit Sub
End If' Upload a file.
Dim localFilename As String
localFilename = "hamlet.xml"
Dim remoteFilename As String
remoteFilename = "hamlet.xml"success = ftp.PutFile(localFilename,remoteFilename)
If (success <> 1) Then
MsgBox ftp.LastErrorText
Exit Sub
End Ifftp.Disconnect MsgBox "File Uploaded!"我帮你搜了一个。
更多参考如下:
http://www.example-code.com/vb/ftp.asp
Attribute VB_Name = "WinInetAPI"
Option ExplicitConst ErrFolder As String = "\ErrorLogs" 'folder Name for errorlog text files
Const ErrFile As String = "\errlog" 'errorlog text File Name
Private iCount As Long 'error message counterPublic Const sSlash = "/"Public Const MAX_PATH As Long = 260
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0 ' use registry configuration
Public Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net
Public Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy
Public Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ' prevent using java/script/INSPublic Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections
Public Const INTERNET_FLAG_RELOAD = &H80000000
========================================================================================
part (2)
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsFTP"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'********************************************************************************
' Class: clsFTP
'--------------------------------------------------------------------------------
' Description:
' This class allows to connect to FTP site using WinInet API calls
' and download files from FTP Directory
'---------------------------------------------------------------------------------
' Methods: OpenConnection - opens FTP connection, gets internet Handle
' CloseConnection - closes FTP connection
' DownloadFile - downloads file from FTP site to defined destination
' UploadFile - copies a file from your local machine to a FTP site
' DeleteFile - deletes a file from a FTP site
' RenameFile - renames a file on a FTP site
' CheckFile - checks if specified file exist on FTP site
' EnumDirectory - Returns a list of files and folders in a path
' ChangeDirectory - Changes the current directory