以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  有点不好意思,请老师帮着写一段需要上传的图片自动压缩持尺寸的代码?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=109930)

--  作者:fczhaobo
--  发布时间:2017/11/22 23:07:00
--  有点不好意思,请老师帮着写一段需要上传的图片自动压缩持尺寸的代码?
Dim ftp1 As New FtpClient
ftp1.Host="***"
ftp1.Account = "***"
ftp1.Password = "****
图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看
"
ftp1.Port="22"
ftp1.UTF8 = True
ftp1.Connect
ftp1.RootDir = "\\photo\\staff"
If ftp1.Connected=True Then
    Dim dlg As New OpenFileDialog
    dlg.Filter= "图形文件|*.bmp;*.jpg;*.gif"
    If dlg.ShowDialog = DialogResult.OK Then
        MessageBox.Show("你选择的是:" & dlg.FileName,"提示") \'提示用户选择的文件
        \'Dim piv As WinForm.PictureViewer = e.Form.Controls("员工照片")
        Dim gh As WinForm.TextBox = e.Form.Controls("工号")
        If gh.value ="" Then
            msgbox("请确认员工编号!")
            Return
        End If
        Dim nm As String = gh.value & ".jpg"
        Dim pth As String = dlg.FileName
        Dim files = ftp1.GetFileList("\\photo\\staff")
        If files.contains(nm) Then \'判断是否有重名的图片
            Dim Result As DialogResult
            Result = MessageBox.Show("该名员工已经上传过相片,是否重新上传替换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If Result = DialogResult.Yes Then
                ftp1.DeleteFile(nm)
                ftp1.Upload(pth,nm)
msgbox("员工照片上传成功!")
            End If
        Else
            If ftp1.Upload(pth,nm) = True Then
                Dim r As DataRow =DataTables("职员表").SQLFind("工号=\'" & gh.value &   "\'")
                If r IsNot Nothing Then
                    r("员工照片")= "\\photo\\staff\\" & nm
                    r.Save
                Else
                    _piclujing="\\photo\\staff\\" & nm
                End If
                Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                
            Else
                Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If
        End If
    End If
Else
    MessageBox.show("服务器连接失败!")
End If

--  作者:有点甜
--  发布时间:2017/11/22 23:26:00
--  

参考

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=109523&skin=0