Foxtable(狐表)用户栏目专家坐堂 → 压缩上传


  共有2591人关注过本帖树形打印复制链接

主题:压缩上传

帅哥哟,离线,有人找我吗?
刘林
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
压缩上传  发帖心情 Post By:2020/4/23 10:02:00 [只看该作者]

Dim ftp1 As New FtpClient
ftp1.Host="
ftp1.Account = 
ftp1.Password = 
Dim wjm As String=""
If Tables("拍户口_table1").Rows.Count>0
    Dim r As Row = Tables("拍户口_table1").Current
    If ValidPIN(r("身份证件号"))= True
        wjm = r("身份证件号") & ".jpg"
    ElseIf r("学籍号")>""
        wjm= r("学籍号") & ".jpg"
    Else
        messagebox.show("该学生的身份证号和学籍号中至少有一个要正确完整")
        Return
    End If
    If wjm>""
        Dim pic As WinForm.PictureBox = e.Form.Controls("PicView2")
        Dim img As Image
        If pic.Image IsNot Nothing
            Dim buffer() As Byte = Functions.Execute("GetImageToBytes",pic.Image)
            Dim result As Integer = Functions.Execute("SaveBytesToFile",buffer,wjm)
            Dim fl As String=ProjectPath & "RemoteFiles\xp\" & FileSys.GetName(wjm)
            pic.image.save(fl)
            Dim fileInfo As new FileInfo(fl)
            Dim file As String = fl
            img  = getImage(file)
            Dim bmp As bitmap
            bmp = new bitmap(img, 100, 100 * (img.height / img.width))
            bmp.save(ProjectPath & "RemoteFiles\xp\" & FileSys.GetName(wjm), ImageFormat.Jpeg)
            bmp.Dispose
            Dim ifo As new FileInfo(wjm)
            If ftp1.Upload(wjm,"\xp\" & FileSys.GetName(wjm),True) = True Then
                r("相片")="\xp\" & FileSys.GetName(wjm)
                r.save
                With Tables("拍户口_table1")
                    If  .Position = .Rows.Count - 1
                        .Position = .Position - 1
                        .Position = .Position + 1
                    Else
                        .Position = .Position + 1
                        .Position = .Position - 1
                    End If
                End With
            Else
                Messagebox.show("上传失败,请重新上传该文件!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If            
        Else
            MessageBox.Show("保存失败","失败")
        End If
        
    Else
        MessageBox.Show("请先拍照!","错误")
    End If
End If


老师:你好,之前我也做过压缩,这个地方没做压缩,发现用户上读的图片很大,现在才发现,又很急越急越晕,增加压缩这样好像没压缩起,请老师帮改下压缩文件大小,谢谢!

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107718 积分:547917 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/4/23 10:35:00 [只看该作者]

If pic.Image IsNot Nothing
    Dim bmp As bitmap
    bmp = new bitmap(pic.Image, 100, 100 * (pic.Image.height / pic.Image.width))
    bmp.save(ProjectPath & "RemoteFiles\xp\" & FileSys.GetName(wjm), ImageFormat.Jpeg)
    bmp.Dispose
   If ftp1.Upload(wjm,"\xp\" & FileSys.GetName(wjm),True) = True Then

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2020/4/23 12:21:00 [只看该作者]

老师,这样出现上传时项目就出现停止运行然后就关闭了呢

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107718 积分:547917 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/4/23 13:41:00 [只看该作者]

If pic.Image IsNot Nothing
dim filename as string = FileSys.GetName(wjm)
dim fpath as string = ProjectPath & "RemoteFiles\xp\" & filename 
    Dim bmp As bitmap
    bmp = new bitmap(pic.Image, 100, 100 * (pic.Image.height / pic.Image.width))
    bmp.save( fpath, ImageFormat.Jpeg)
    bmp.Dispose
   If ftp1.Upload( fpath,"\xp\" & filename ,True) = True Then

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2020/4/26 15:06:00 [只看该作者]

Dim ftp1 As New FtpClient
ftp1.Host=""
ftp1.Account = ""
ftp1.Password = ""
Dim tb As Table =Tables("贴图_table1")
If tb.Rows.Count>0
    Dim r As Row = tb.Current
    Dim t1 As String = e.Form.Controls("textbox1").text
    Dim t2 As String = e.Form.Controls("textbox2").text
    Dim t3 As String = e.Form.Controls("textbox3").text
    Dim wjm As String=""
    If ValidPIN(r("身份证件号"))= True
        wjm = r("身份证件号")
    ElseIf r("学籍号")>""
        wjm =r("学籍号")
    Else
        messagebox.show("该学生的身份证号和学籍号中至少有一个要正确完整")
        Return
    End If
    If t1>""
        Dim ifo As new FileInfo(t1)
        If  Ifo.Length>40960 '大于40k才压缩
            Dim img As image = getimage(t1)
            Dim bmp As new bitmap(img.width, img.height)
            Dim g = graphics.fromimage(bmp)
            g.DrawImage(img, 0, 0, img.Width, img.Height)
            Dim jpgEncoder As ImageCodecInfo
            Dim codecs() As ImageCodecInfo = ImageCodecInfo.GetImageDecoders
            For Each codec As ImageCodecInfo In codecs
                If (codec.FormatID = ImageFormat.Jpeg.Guid) Then
                    jpgEncoder = codec
                    Exit For
                End If
            Next
            Dim myEncoder As System.Drawing.Imaging.Encoder = System.Drawing.Imaging.Encoder.Quality
            Dim myEncoderParameters As EncoderParameters = New EncoderParameters(1)
            Dim myEncoderParameter As EncoderParameter = New EncoderParameter(myEncoder, 100) ' 质量级别 0 对应于最大压缩,而质量级别 100 对应于最小压缩
            myEncoderParameters.Param(0) = myEncoderParameter
            Dim slt As String =  ifo.path & wjm & ifo.Extension
            bmp.Save(slt,jpgEncoder, myEncoderParameters)
            bmp.dispose
            g.dispose
            Dim img1 As image = getImage(slt)
            Dim bmp1 As bitmap
            If img1.width > 400 Then
                If 400 * (img1.height / img1.width) > 300 Then
                    bmp1 = new bitmap(img1, 400*(300/(400*(img1.height/img1.width))), 300)
                Else
                    bmp1 = new bitmap(img1, 300, 300 * (img1.height / img1.width))
                End If
                bmp1.save(slt, ImageFormat.Jpeg)
                bmp1.Dispose
            End If
            If ftp1.Upload(slt,"\xp\" & FileSys.GetName(wjm & Ifo.extension),True) = True Then
                r("相片")="\xp\" & FileSys.GetName(wjm & Ifo.extension)
                r.save
                e.Form.Controls("PictureBox1").image=getimage(slt)
           
            Else
                Messagebox.show("上传失败,请重新上传该文件!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If
        Else
            If ftp1.Upload(t1,"\xp\" & FileSys.GetName(wjm & Ifo.extension),True) = True Then
                r("相片")="\xp\" & FileSys.GetName(wjm & Ifo.extension)
                r.save
            Else
                Messagebox.show("上传失败,请重新上传该文件!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If
        End If
    End If
    

老师,这个代码之可以用,但现在出现有的电脑传一张图片就显示停止运行,然后就关闭了,这是什么原因,怎么改进这个
    


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107718 积分:547917 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/4/26 15:15:00 [只看该作者]

试试去掉图片框的列绑定

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2020/4/26 16:42:00 [只看该作者]

不绑定又如何让PICTUREBOX.随着记录变动显示远程图片呢

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2020/4/26 17:16:00 [只看该作者]


Dim pc1 As WinForm.PictureBox = e.Form.Controls("picturebox1")
Dim ftp1 As New FtpClient
ftp1.Host=
ftp1.Account = 
ftp1.Password = 
Dim tb As Table=Tables("贴图_table1")
Dim Key As String =tb.Current("相片") '获取此员工的照片文件
If ftp1.Download(key,ProjectPath & "remotefiles" & Key) = False
    pc1.Image= GetImage(ProjectPath & "images\wxp.jpg")
Else
    pc1.Image= GetImage(projectPath & "remotefiles" & key)
End If

老师,不绑相片列,为了显示远程图片这样写了,但有个问题明显卡,如何解决更好呢

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107718 积分:547917 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/4/26 17:25:00 [只看该作者]

先判断remotefiles目录有没有这个文件,没有再下载,如果有直接使用,不要下载了

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2020/4/26 17:28:00 [只看该作者]

这样也有个问题,如果远程文件变了,但文件名没变,这样就得不到远程更新后的,
[此贴子已经被作者于2020/4/26 17:28:13编辑过]

 回到顶部
总数 12 1 2 下一页