以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  上传图片按钮  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=142115)

--  作者:yifan3429
--  发布时间:2019/10/18 17:58:00
--  上传图片按钮

想做一个上传图片按钮

根据当前订单表选择的行 的客户列,地址列,单号列重命名文件
同时需要压缩图片尺寸,存到指定的目录

[此贴子已经被作者于2019/10/18 17:58:02编辑过]

--  作者:有点蓝
--  发布时间:2019/10/18 20:41:00
--  
参考:http://www.foxtable.com/webhelp/topics/1410.htm

类似

Dim r As rwo = Tables().current
If r Is Nothing Then Return
Dim f1 As String = r("客户列") & r("地址列") & r("单号列")
Dim dlg As New OpenFileDialog
dlg.Filter= "图片文件|*.jpg;*.png"
If dlg.ShowDialog = DialogResult.OK Then
    Dim f2 As String = FileSys.GetName(dlg.FileName)
    Dim name As String = f1 & "." & f2.Split(".")(1)

    Dim img As image = getImage(dlg.FileName)
    Dim bmp As bitmap
    If img.width > 400 Then
        If 400 * (img.height / img.width) > 300 Then
            bmp = new bitmap(img, 400*(300/(400*(img.height/img.width))), 300)
        Else
            bmp = new bitmap(img, 400, 400 * (img.height / img.width))
        End If
    End If
    bmp.save(ProjectPath & name,img.RawFormat)
    bmp.Dispose
    

    Dim ftp1 As New FtpClient
    ftp1.Host="196.128.143.28"
    ftp1.Account = "foxuser"
    ftp1.Password = "138238110"
    If ftp1.Upload(ProjectPath & name ,name ) = True Then
        Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If