在微信浏览器中使用相机

如果你的手机是安卓系统,并且使用的是微信内置的浏览器浏览WeUI生成的网页,你会发现Uploader只能从相册中选择图片上传,无法使用相机拍照上传。

要解决这个问题很简单, 只需将Uploader的Accept属性设置为"image/*",例如:

Select Case e.Path

    Case "test.htm"
        Dim wb As New weui
        wb.AddForm("","form1","test.htm")
        With wb.AddInputGroup("form1","ipg22",
"
文件上传")
            With .AddUploader("up2",
"
图片",True)
                .Accept = "image/*"  
'
允许使用相册和相机

            End With
        End With
        With wb.AddButtonGroup("form1","btg1",True)
            .Add("btn1",
"
确定", "submit")
        End With
        e.WriteString(wb.Build)

End
Select

如果希望不能从相册选择,而是直接拍照上传,可以再将Capture属性设置为"camera",例如:

Select Case e.Path
    Case "test.htm"
        Dim wb As New weui
        wb.AddForm("","form1","test.htm")
        With wb.AddInputGroup("form1","ipg22",
"
文件上传")
            With .AddUploader("up2",
"
图片",True)
                .Accept = "image/*"  
                .Capture = "camera"
'
只能拍照上传
            End With
        End With
        With wb.AddButtonGroup("form1","btg1",True)
            .Add("btn1",
"
确定", "submit")
        End With
        e.WriteString(wb.Build)

End
Select


本页地址:http://www.foxtable.com/mobilehelp/topics/0287.htm