代码如下:
Dim ftpurl As String
Dim ftpuser As String
Dim ftppass As String
Dim ftppath As String
Dim taner_upfile As String Label1.Caption = "状态: 开始上传..."
Label1.Refresh
Randomize Timer
upcode = Left(Int(Rnd * 9998) + 1000, 4)
ftpurl = "123.123.123"
ftpuser = "123"
ftppass = "123" ftppath = "/www/TmpImageL/"
On Error GoTo ConError Inet1.URL = "ftp://" & ftpurl & "/"
Inet1.Protocol = 2
Inet1.UserName = ftpuser
Inet1.password = ftppass
Inet1.RequestTimeout = "10"
taner_upfile = FileAdd
fileExt1 = RightB(taner_upfile, 8)
If InStrB(fileExt1, ".") > 0 Then
fileExt2 = Split(fileExt1, ".")
fileExt = fileExt2(1)
Else
fileExt = Replace(fileExt1, ".", "")
End If
filesize = FileLen(taner_upfile)
newfilename = ftppath & "000." & fileExt
Inet1.Execute , "PUT " & "" & taner_upfile & "" & " " & newfilename & ""
If Inet1.StillExecuting = True Then
Label1.Caption = "状态: 正在上传图片"
ProgressBar.Max = 100
ProgressBar.Value = 1
Label1.Refresh
Do While Inet1.StillExecuting = True
If ProgressBar.Value <= 99 Then ProgressBar.Value = ProgressBar.Value + 1
DoEvents
Loop
ProgressBar.Value = 100
Label1.Caption = "状态: 上传完毕"
MsgBox "上传完毕!"
Else
MsgBox "上传失败!" & Chr(13) & "请将要上传的图片放在D盘!"
End IfConError: If Err.Number <> 0 Then
MsgBox "服务器连接失败!", vbInformation, "提示"
Label2.Caption = "上传失败"
Exit Sub
End If=========================================运行之后,在 Do While Inet1.StillExecuting = True
If ProgressBar.Value <= 99 Then ProgressBar.Value = ProgressBar.Value + 1
DoEvents
Loop这里进入了死循环,Inet1.StillExecuting 返回值一直为TRUE,然后用CUTFTP查看FWQ "/www/TmpImageL/"目录, 000.JPG 文件的大小为0 KB请各位帮忙解决下,小弟感激不尽
Dim ftpurl As String
Dim ftpuser As String
Dim ftppass As String
Dim ftppath As String
Dim taner_upfile As String Label1.Caption = "状态: 开始上传..."
Label1.Refresh
Randomize Timer
upcode = Left(Int(Rnd * 9998) + 1000, 4)
ftpurl = "123.123.123"
ftpuser = "123"
ftppass = "123" ftppath = "/www/TmpImageL/"
On Error GoTo ConError Inet1.URL = "ftp://" & ftpurl & "/"
Inet1.Protocol = 2
Inet1.UserName = ftpuser
Inet1.password = ftppass
Inet1.RequestTimeout = "10"
taner_upfile = FileAdd
fileExt1 = RightB(taner_upfile, 8)
If InStrB(fileExt1, ".") > 0 Then
fileExt2 = Split(fileExt1, ".")
fileExt = fileExt2(1)
Else
fileExt = Replace(fileExt1, ".", "")
End If
filesize = FileLen(taner_upfile)
newfilename = ftppath & "000." & fileExt
Inet1.Execute , "PUT " & "" & taner_upfile & "" & " " & newfilename & ""
If Inet1.StillExecuting = True Then
Label1.Caption = "状态: 正在上传图片"
ProgressBar.Max = 100
ProgressBar.Value = 1
Label1.Refresh
Do While Inet1.StillExecuting = True
If ProgressBar.Value <= 99 Then ProgressBar.Value = ProgressBar.Value + 1
DoEvents
Loop
ProgressBar.Value = 100
Label1.Caption = "状态: 上传完毕"
MsgBox "上传完毕!"
Else
MsgBox "上传失败!" & Chr(13) & "请将要上传的图片放在D盘!"
End IfConError: If Err.Number <> 0 Then
MsgBox "服务器连接失败!", vbInformation, "提示"
Label2.Caption = "上传失败"
Exit Sub
End If=========================================运行之后,在 Do While Inet1.StillExecuting = True
If ProgressBar.Value <= 99 Then ProgressBar.Value = ProgressBar.Value + 1
DoEvents
Loop这里进入了死循环,Inet1.StillExecuting 返回值一直为TRUE,然后用CUTFTP查看FWQ "/www/TmpImageL/"目录, 000.JPG 文件的大小为0 KB请各位帮忙解决下,小弟感激不尽
如:
http://www.skycn.com/soft/24185.html
http://download.pchome.net/development/activex/6853.html
...
要复杂点的实现可以用Winsock控件实现FTP协议来操作.再复杂点连Winsock都可以用API封装成控件或类来实现FTP协议通讯。用Inet控件不是什么很好的选择。
谢谢SupermanKing 的建议,其实我还想了解下为什么会出现这样的问题