Foxtable(狐表)用户栏目专家坐堂 → 拍照、压缩、上传死机


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

主题:拍照、压缩、上传死机

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


加好友 发短信
等级:八尾狐 帖子:1942 积分:14943 威望:0 精华:0 注册:2016/4/28 9:58:00
拍照、压缩、上传死机  发帖心情 Post By: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、是基本要死机返回,除非图片较小,这该怎么来提高效果?


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


加好友 发短信
等级:超级版主 帖子:109736 积分:558396 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/9/30 10:06:00 [只看该作者]

请新建项目做一个可以测试的实例发上来。

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

 回到顶部