>应客户的要求 给以前开发的应用程序增加了远程保存附件的功能, 主要是用在一些合同用高拍仪拍摄上传到远程服务器里使用。 就在客户那边搭建个FTP服务器 也可以用NAS 如群晖之类的实现,加了几行代码实现了。 本想做上传进度条的, 想想现在宽带速度足够快,再加上我这里主要上传PDF文件,一般也就几百K 最多2-3M,就偷懒了。。
Function FtpUpfile(LocalFileName As String, FtpFileName) As String '上传文件 Inet1.URL = "ftp://" & ftpUserName & ":" & ftpPassWord & "@" & ftpServer & ":" & ftpPORT & "/ftp" Inet1.Protocol = icFTP Inet1.RemoteHost = ftpServer Inet1.RemotePort = CInt(ftpPORT) Inet1.UserName = ftpUserName Inet1.PassWord = ftpPassWord Dim right1 As Boolean Inet1.Execute "ftp://" & ftpUserName & ":" & ftpPassWord & "@" & ftpServer & ":" & ftpPORT & "", _ "PUT " & " " & LocalFileName & " \ftp\" & FtpFileName right1 = Inet1.StillExecuting Do While right1 right1 = Inet1.StillExecuting DoEvents Loop txtData = "" FtpUpfile = "OK" End Function 上面是上传 下载改成 Inet1.Execute "ftp://" & ftpUserName & ":" & ftpPassWord & "@" & ftpServer & ":" & ftpPORT & "", _ "GET /ftp/" & ListVFJ.ListItems(i).SubItems(1) & " " & App.Path & "\pdf\" & ListVFJ.ListItems(i).SubItems(1) 删除文件 Inet1.Execute "ftp://" & ftpUserName & ":" & ftpPassWord & "@" & ftpServer & ":" & ftpPORT & "", _ "DELETE /ftp/" & ListVFJ.ListItems(i).SubItems(1) 其他FTP命令也类似
发表评论