Access开发平台--上传下载函数,实现通用附件支持FTP。
时 间:2019-04-17 00:52:35
作 者:丘苏洲 ID:66601 城市:普宁
摘 要:开发平台上传下载函数,实现通用附件支持FTP。
正 文:
Access快速开发平台通用附件的图片用共享文件夹的方式,安全性能不高,可能存在误删除。把图片文件用FTP的方法保存,在客户端开通FTP即可实现通用附件的FTP网络服务器实时共享。
优点是括大了服务器的应用范围,缺点是每次浏览都要重新下载更新图片文件,性能不如共享。
一、企业版:设置开发平台FTP:
专业版在系统表 Sys_ServerParameters 手工增加以下内容即可。
二、复制上传,下载自定义函数代码到“模块”
三、在 通用附件窗体(SysFrmAttachments) 下新增红字调用函数代码:
代码所在位置请自行对应。
四、架设FTP服务器方法请自行查找。
1、保存事件
Public Function SaveAttachmentData(DataCategory As String _
, DataID As Variant _
, Optional ActiveConnection As Variant _
)
‘中间部分省略
rst![AttachmentName] = rstTmp![AttachmentName]
uploadFTPfile rstTmp![AttachmentName] '上传到FTP
rst.Update
‘中间部分省略
2、加载浏览事件
Public Function LoadAttachmentData(DataCategory As String _
, DataID As Variant _
, Optional ActiveConnection As Variant _
)
‘中间部分省略
rstTmp![AttachmentName] = rst![AttachmentName]
downloadFTPfile rst![AttachmentName] '下载FTP到本地
rstTmp.Update
‘中间部分省略
附上传及下载函数:
Function downloadFTPfile(downFILEname As String) As Boolean
On Error GoTo ErrorHandler
'下载 FTP 文件
If getParameter("FTP Server Address", dbText, "", , , True) = "" Then GoTo ExitHere
Dim AttPATH As String
'本地保存路径设置
AttPATH = getParameter("Attachment Path", dbText, "", , , True)
If Len(AttPATH) = 0 Then AttPATH = CurrentProject.Path & "\Attachments\"
If Left(AttPATH, 2) = ".\" Then AttPATH = CurrentProject.Path & Mid(AttPATH, 2)
If Right(AttPATH, 1) <> "\" Then AttPATH = AttPATH & "\"
If dir(AttPATH)="" then mkdir(AttPATH)
With FTPServer
.OpenConnection ‘专业版需直接使用参数 getParameter("FTP Server Address", dbText, "", , , True),getParameter("FTP Server Port", dbText, "", , , True),getParameter("FTP Server Username", dbText, "", , , True),getParameter("FTP Server Password", dbText, "", , , True)
If .FileExists("Attachments\" & downFILEname) Then .DownloadFile "Attachments\" & downFILEname, AttPATH & downFILEname
.CloseConnection
End With
ExitHere:
downloadFTPfile = True
Exit Function
ErrorHandler:
downloadFTPfile = False
End Function
Function uploadFTPfile(upFILEname As String) As Boolean
On Error GoTo ErrorHandler
'上传 FTP 文件
If getParameter("FTP Server Address", dbText, "", , , True) = "" Then GoTo ExitHere
Dim AttPATH As String
'本地保存路径设置
AttPATH = getParameter("Attachment Path", dbText, "", , , True)
If Len(AttPATH) = 0 Then AttPATH = CurrentProject.Path & "\Attachments\"
If Left(AttPATH, 2) = ".\" Then AttPATH = CurrentProject.Path & Mid(AttPATH, 2)
If Right(AttPATH, 1) <> "\" Then AttPATH = AttPATH & "\"
With FTPServer
.OpenConnection ‘专业版需直接使用参数 getParameter("FTP Server Address", dbText, "", , , True),getParameter("FTP Server Port", dbText, "", , , True),getParameter("FTP Server Username", dbText, "", , , True),getParameter("FTP Server Password", dbText, "", , , True)
'判断FTP是否存在Attachments文件夹
If .FileExists("Attachments") = False Then .CreateDirectory "Attachments"
If Dir(AttPATH & upFILEname) <> "" Then .UploadFile AttPATH & upFILEname, "Attachments\" & upFILEname
.CloseConnection
End With
ExitHere:
uploadFTPfile = True
Exit Function
ErrorHandler:
uploadFTPfile = False
End Function
Access快速开发平台QQ群 (群号:321554481) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access选项卡示例】Ac...(09.09)
- 【Access源码示例】按输入...(09.02)
- 【Access日期区间段查询】...(08.29)
- 【Access日期区间段查询】...(08.27)
- Access怎样才能实现日期时...(08.21)
- 【Access定时打开查询】A...(08.19)
- Access生成固定数量的记录...(08.13)
- Access怎样才能实现日期时...(08.12)
- Access利用导航窗体控件对...(08.03)
学习心得
最新文章
- Access表中的字段名、字段标题...(09.19)
- Access快速开发平台--更改“...(09.18)
- 【中秋及国庆优惠】Access培训...(09.15)
- Access如何将日期型的数值转换...(09.14)
- 英文输入法输入数据中存在单引号引起...(09.11)
- 【Access选项卡示例】Acce...(09.09)
- 让Access光标停留在指定的控件...(09.07)
- 关于Access查询条件里使用通配...(09.06)
- Access报表偷懒制作法--Ac...(09.05)
- Access快速开发平台--窗体数...(09.04)