以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  拍照、压缩、上传死机  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=125521)

--  作者:刘林
--  发布时间:2018/9/30 8:20:00
--  拍照、压缩、上传死机
Dim e As RequestEventArgs = args(0)
Dim path As String = "foxtableAppTest"
Dim wb As New weui
wb.AddPageTitle("","xp","相片上传","近期正面规范证件照")
wb.AddForm("","form1","xsxpcjsave.htm")
wb.InsertHTML("form1","<div style=\'height: 150px\'><span style=\'position:absolute;margin-top:60px;margin-left:20px;\'>学生照片:</span><img src=\'./xp/" & e.Cookies("xssfzh") & ".jpg\' style=\'height: 150px;width:120px;margin-left:120px;max-height:100%\'></div>")
If ReadSex(e.Cookies("xssfzh"))= "女"
    wb.InsertHTML("form1","<div style=\'height: 150px\'><span style=\'position:absolute;margin-top:80px;margin-left:20px;\'>样板照片:</span><div id=\'imgs\'><img src=\'./xp/yb.jpg\' style=\'height:150px;width:120px;margin-top:20px;margin-left:120px;max-height:100%;\'></div></div><br/>")
End If
If ReadSex(e.Cookies("xssfzh"))= "男"
    wb.InsertHTML("form1","<div style=\'height: 150px;width:120px;\'><span style=\'position:absolute;margin-top:80px;margin-left:20px;\'>样板照片:</span><div id=\'imgs\'><img src=\'./xp/yb1.jpg\' style=\'height:100%;width:100%;margin-top:20px;margin-left:120px;max-height:100%;\'></div></div><br/>")
End If
With wb.AddPageFooter("form1","pf1","")
    With wb.AddButtonGroup("form1","btg1",False)
        .Add("btn1", "拍照", "button").Attribute = """
        .Add("btn1", "上传")
       .Add("btn1","退出","button").Attribute=""
     End With
End With
wb.AppendHTML("<script type=\'text/javascript\' src=\'/" & path & "/js/camera.js\'></script>")
wb.AppendHTML("<script type=\'text/javascript\' src=\'/" & path & "/js/common.js\'></script>", True)
e.WriteString(wb.Build)







Dim e As RequestEventArgs = args(0)
Dim wb As new weui
For Each key As String In e.PostValues.Keys
    If key.Contains("imgs_") Then
        Dim bs As Byte() = Convert.FromBase64String(e.PostValues(key).split(",")(1))
        Dim stream As System.IO.Stream = New System.IO.MemoryStream(bs)
        Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(stream)
        bmp.Save("c:\\web\\xp\\" & e.Cookies("xssfzh") & ".jpg", ImageFormat.Jpeg)
        Dim slt As String ="c:\\web\\xp\\" & e.Cookies("xssfzh") & ".jpg"
        Dim img1 As image = getImage(slt)
        Dim bmp1 As bitmap
        If img1.width > 200 Then
            If 200 * (img1.height / img1.width) > 150 Then
                bmp1 = new bitmap(img1, 200*(150/(200*(img1.height/img1.width))), 150)
            Else
                bmp1 = new bitmap(img1, 150, 150 * (img1.height / img1.width))
            End If
        End If
        bmp1.save(slt, ImageFormat.Jpeg)
        bmp1.Dispose
           End If
Next
With wb.AddMsgPage("","msgpage","上传成功", "") \'生成成功提示页
   \' .AddButton("btn1","返回","javascript:history.back()")
 
End With

e.WriteString(wb.Build)



请问老师,拍照压缩并上传,一直都是这个问题:1、是上传慢;2、是基本要死机返回,除非图片较小,这该怎么来提高效果?


--  作者:有点蓝
--  发布时间:2018/9/30 10:06:00
--  
请新建项目做一个可以测试的实例发上来。

或者直接在js里压缩后在上传:https://www.baidu.com/baidu?word=js+压缩图片