Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共6 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:上传图片后,图片自动命名问题

1楼
BIAO 发表于:2025/5/15 11:21:00

1.需求是:各项目上传照片后,该照片会自动重命名为:项目名称+时间戳

2.在该表的表事件BeforeAttachFile里面写了代码,但是上传图片后没有重命名,图片还是原名称

代码如下:

Dim now As String = Format(Date.now, "yyyyMMddHHmmss")
Dim dr As DataRow = e.DataRow
 If dr.IsNull("项目名称") Then
    MessageBox.Show("请先输入项目名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
     e.Cancel = True
 Else
     e.FileName = dr("项目名称") & now & ".jpg"
 End If

2楼
有点蓝 发表于:2025/5/15 11:27:00
使用的ftp?
3楼
BIAO 发表于:2025/5/15 11:36:00
是的,ftp
4楼
有点蓝 发表于:2025/5/15 12:01:00
这个表事件的功能不支持ftp的。只能另外设计窗口,手工使用ftpclient上传文件:http://www.foxtable.com/webhelp/topics/1410.htm
5楼
BIAO 发表于:2025/5/15 15:51:00
在beforeupload事件里面写代码?有参考代码不?
6楼
有点蓝 发表于:2025/5/15 16:24:00
设计窗口,按钮,比如添加一个上传按钮,代码比如
dim r as row = tables("表A").current
if r is nothing then return

Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= 
"图片文件|*.jpg" '设置筛选器
If
 dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim now As String = Format(Date.now, "yyyyMMddHHmmss")
dim name as string = r("项目名称") & now & ".jpg"
Dim ftp1 As New FtpClient
ftp1
.Host="196.128.143.28"
ftp1
.Account = "foxuser"
ftp1
.Password = "138238110"
If 
ftp1.Upload(dlg.FileName,name ) = True Then
    
Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    
Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If

End
 
If
共6 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02637 s, 2 queries.