以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 关于照相 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=147804) |
-- 作者:刘林 -- 发布时间:2020/3/24 16:10:00 -- 关于照相 wb.AddForm("","form1","receive.htm") With wb.AddInputGroup("form1","ipg1","") With .AddUploader("up1","近期免冠证件照",True) .AddImage("./xp/" & e.Cookies("username") & ".jpg") .AllowDelete = False \'允许删除 .Incremental = True \'允许重复选择文件或连续拍照 .Accept = "image/*" .ScaleWidth=400 End With With .AddUploader("up2","户口本主页照片",True) .AddImage("./fk/" & e.Cookies("username") & "A.jpg") .AllowDelete = False \'允许删除 .Incremental = True \'允许重复选择文件或连续拍照 .Accept = "image/*" .ScaleWidth=400 End With With .AddUploader("up3","户口本人页照片",True) .AddImage("./fk/" & e.Cookies("username") & "B.jpg") .AllowDelete = False \'允许删除 .Incremental = True \'允许重复选择文件或连续拍照 .Accept = "image/*" .ScaleWidth=400 End With End With wb.InsertHTML("form1","<p>1.学生本人相片应为清晰蓝底证件照;凡学校未要求时不得上传照片</p>") wb.InsertHTML("form1","<p>2.户口分别提交户主首页和本人页;</p>") With wb.AddButtonGroup("form1","btg1",True) Dim btn1 = .Add("btn1", "确定", "button") btn1.kind=1 btn1.attribute=" style=\'border:1px solid black;border-radius:20px;padding:0px;width:50%\'" End With 老师:一直有个问题没得到根本解决,在网页中打开上面代码是可以同时调出相机或相册,但用hbulider打包后手机APP测试就只能有相册,这造成很不方便,这个有什么办法改进?
|
-- 作者:有点蓝 -- 发布时间:2020/3/24 16:19:00 -- 这种是网页的通用用法,如果不支持,我们也没有办法。hbulider应该是有自己专门的接口调用相机的。 |
-- 作者:刘林 -- 发布时间:2020/3/24 18:53:00 -- 老师请问我用例子来改,up1可以打开相册,拍照在app中可以调摄像头,我想到照的图片放在imes中,如果重拍覆盖,现这是样是拍一张又追加一张,这怎么改呢 wb.AppendHTML("<script type=\'text/javascript\' src=\'../mui/js/common.js\'></script>", True) wb.AddForm("","form1","submit.htm") With wb.AddInputGroup("form1","ipg1","测试") .AddUploader("up1","照片",True) \'True表示允许上传多个文件 End With wb.InsertHTML("form1", "<div id=\'imgs\' style =\'width:140px;height:180px;border:1px solid red\'></div>") With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "拍照", "button").Attribute = """ End With With wb.AddButtonGroup("form1","btg2",True) .Add("btn1", "提交") End With wb.AppendHTML("<script type=\'text/javascript\' src=\'../mui/js/camera.js\'></script>") e.WriteString(wb.Build) e.Handled= True var count = 1; function getImageByCamera(id) {
plus.camera.getCamera().captureImage(function(p) {
var imgs = document.getElementById(id);
plus.io.resolveLocalFileSystemURL(p, function(entry) {
entry.file(function(file) {
var url = entry.toLocalURL();
var name = "_doc/upload/" + entry.name;
plus.zip.compressImage({
src: url, //src: (String 类型 )压缩转换原始图片的路径
dst: name, //压缩转换目标图片的路径
quality: 100, //quality: (Number 类型 )压缩图片的质量.取值范围为1-100
overwrite: true //overwrite: (Boolean 类型 )覆盖生成新文件
},
function(zip) {
//页面显示图片
showPics(zip.target, name, id);
},
function(error) {
plus.nativeUI.toast("压缩图片失败,请稍候再试");
});
});
});
}); } function showPics(p, name, id) {
var imgs = document.getElementById(id);
plus.io.resolveLocalFileSystemURL(p, function(entry) {
entry.file(function(file) {
var fileReader = new plus.io.FileReader();
fileReader.readAsDataURL(file);
fileReader.onloadend = function(e) {
var picUrl = e.target.result.toString();
imgs.innerHTML += "<img src=\'" + picUrl + "\' width=\'140px\' height=\'180px\'/><input type=\'hidden\' name=\'" + id + "_" + count + "\' value=\'" + picUrl + "\'/>"
count++;
}
});
}); }
|
-- 作者:有点蓝 -- 发布时间:2020/3/24 20:14:00 -- imgs.innerHTML += "<img src=\'" + 改为 imgs.innerHTML = "<img src=\'" +
|
-- 作者:刘林 -- 发布时间:2020/3/24 20:49:00 -- 老师,请问如何实现点拍照弹出选择相机或相册呢 |
-- 作者:有点蓝 -- 发布时间:2020/3/24 20:54:00 -- 这个请去看hbuilder的接口说明吧 |
-- 作者:刘林 -- 发布时间:2020/3/25 23:07:00 -- 老师为了能调相机和相册,我整了两天差不多可以了 1\\这个页面有mui.init()初始,但点手机返回键要退出,只有点顶部返回可以,其他页面有这个可以,另外这个在本机网页中查看不到源代码,其他可以,懂不起什么原因,请帮指导下 Dim e As RequestEventArgs = args(0) Dim sb As New StringBuilder sb.AppendLine("<meta charset=\'utf-8\'>") sb.AppendLine("<meta name=\'viewport\' c />") sb.AppendLine("<script src=\'../mui/js/mui.min.js\'></script>") sb.AppendLine("<link href=\'../mui/css/mui.css\' rel=\'stylesheet\'/>") sb.AppendLine("<script Type=\'text/javascript\' charset=\'utf-8\'>mui.init();</script>") sb.AppendLine("<header style=\'height:60px;background:#EEEEE0\' class=\'mui-bar mui-bar-nav mui-bar-nav-bg\'>") sb.AppendLine("<a style =\'line-height:40px;\' id=\'icon-menu\' class=\'mui-action-back mui-icon mui-icon-left-nav mui-pull-left\'></a>") sb.AppendLine("<script type=\'text/javascript\' src=\'../mui/js/camera.js\'></script>") sb.AppendLine("<script type=\'text/javascript\' src=\'../mui/js/common.js\'></script>") sb.AppendLine("<form method=\'post\' enctype=\'multipart/form-data\' id=\'form1\' name =\'form1\' action =\'submit.htm\'>") If FileSys.FileExists("c:\\web\\xp\\" & e.Cookies("username") & ".jpg")=True sb.AppendLine("<a class=\'mui-icon mui-pull-right mui-a-color\'><div style=\'width: 40px; height: 40px; float:left; border-radius: 50%; border: 1px solid #eee; overflow: hidden;\'><img src=\'./xp/" & e.Cookies("username") & ".jpg\' width=\'40\' height=\'40\' /></div></a>") Else If ReadSex(e.Cookies("username"))= "女" sb.AppendLine("<a class=\'mui-icon mui-pull-right mui-a-color\'><div style=\'width: 40px; height: 40px; float:left; border-radius: 50%; border: 1px solid #eee; overflow: hidden;\'><img src=\'./xp/tx2.jpg\' width=\'40\' height=\'40\' /></div></a>") End If If ReadSex(e.Cookies("username"))= "男" sb.AppendLine("<a class=\'mui-icon mui-pull-right mui-a-color\'><div style=\'width: 40px; height: 40px; float:left; border-radius: 50%; border: 1px solid #eee; overflow: hidden;\'><img src=\'./xp/tx1.jpg\' width=\'40\' height=\'40\' /></div></a>") End If End If sb.AppendLine("<h1 style =\'line-height:60px;\' class=\'mui-title\'>我的相片</h1>") sb.AppendLine("</header>") sb.AppendLine("<div class=\'mui-content\'>") If ReadSex(e.Cookies("username"))= "女" sb.AppendLine("<div style=\'height: 180px;border:1px solid red; width:50%\'><img src=\'./xp/yb.jpg\' style=\'height:180px;width:140px;max-height:100%;\'></div>") End If If ReadSex(e.Cookies("username"))= "男" sb.AppendLine("<div style=\'display:table-cell;text-align:center;vertical=align:middle;height: 180px; width:50%;margin-top:80px;float:left\'><img src=\'./xp/yb1.jpg\' style=\'height:180px;width:140px;max-height:100%;\'></img></div>") End If If FileSys.FileExists("c:\\web\\xp\\" & e.Cookies("username") & ".jpg")=True sb.AppendLine("<div id =\'imgs\' style=\'display:table-cell;text-align:center;vertical=align:middle;height: 180px; width:50%;margin-top:80px;float:left\'><img style=\'width:140px;height:180px;\' src=\'./xp/" & e.Cookies("username") & ".jpg\'></div>") Else sb.AppendLine("<div id =\'imgs\' style=\'display:table-cell;text-align:center;vertical=align:middle;height: 180px; width:50%;margin-top:80px;float:right\'><img style=\'width:140px;height:180px;\' src=\'./xp/wxp.jpg\'></div>") End If sb.AppendLine("<button id=\'btn1\' name=\'btn1\' type= \'button\' onclick=getImageByCamera(\'imgs\') style=\'position: fixed;left:60px; bottom:10px;z-index:5;height:35px;width:33%;border-radius:20px;line-height:35px;color:white;background-color:dodgerblue\'>相机</button>") sb.AppendLine("<button id=\'btn2\' name=\'btn2\' type =\'button\' onclick=galleryImg(\'imgs\') style=\'position: fixed;right:60px; bottom:10px;z-index:5;height:35px;width:33%;border-radius:20px;line-height:35px;color:white;background-color:dodgerblue\'>相册</button>") sb.AppendLine("<button id=\'btn3\' name=\'btn3\' type =\'sumbit\' style=\'position: fixed;right:60px; bottom:50px;z-index:5;height:35px;width:33%;border-radius:20px;line-height:35px;color:white;background-color:dodgerblue\'>确定</button>") e.WriteString(sb.Tostring) e.Handled= True 2、这个保存图片函数怎样改才行,不得行,谢谢 Dim e As RequestEventArgs = args(0) For Each key As String In e.Files.Keys For Each fln As String In e.Files(key) If FLN>"" Dim ifo As new FileInfo(fln) If key ="imgs" e.SaveFile(key,fln,"c:\\web\\xp\\" & e.Cookies("username") & Ifo.Extension ) \'保存接收到的文件 End If End If Next Next e.WriteString("OK") e.Handled=True [此贴子已经被作者于2020/3/25 23:07:08编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/3/26 8:54:00 -- 如果要学自定义html开发,不要急,先花一周时间学学html基础吧。至少要搞懂一个完整的html网页应该包括什么标签,<html>,<head>,<body>等等标签都是干嘛用的,这些标签里面应该放什么。知其然更要知其所以然。想想自己开发网页多长时间了?基础的东西还是一知半解,从而导致了多少问题,做一个网页出来可能只需要半天,但是花了多少时间去解决这半天背后的问题?磨刀不误砍柴工,如果觉得学习时间会占用工作时间,那么永远都会在修修补补中迷茫着。 修修补补的代价绝对比学习所费的代价更高。 看前面的代码,这种上传的图片都只是放到img标签中,而且是base64数据,这种是无法直接通过按钮submit提交的。建议再看看hbuilder的接口,别人是如何上传图片数据的,应该是要通过ajax处理的
|
-- 作者:刘林 -- 发布时间:2020/3/28 20:11:00 -- Dim e As RequestEventArgs = args(0) Dim wb As new weui wb.AppendHTML("<script type=\'text/javascript\' src=\'../mui/js/common.js\'></script>", True) wb.AddForm("","form1","submit.htm") wb.InsertHTML("form1", "<div id=\'imgs\'></div>") With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "拍照", "button").Attribute = """ End With With wb.AddButtonGroup("form1","btg2",True) .Add("btn1", "提交") End With wb.AppendHTML("<script type=\'text/javascript\' src=\'../mui/js/camera.js\'></script>") e.WriteString(wb.Build) e.Handled= True sumbit 函数 Dim e As RequestEventArgs = args(0) Dim wb As new weui For Each key As String In e.PostValues.Keys messagebox.show(e.PostValues(key)) 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) messagebox.show("c:/web/xp/" & e.Cookies("username") & ".jpg") bmp.Save("c:/web/xp/" & e.Cookies("username") & ".jpg", System.Drawing.Imaging.ImageFormat.Png) End If Next With wb.AddMsgPage("","msgpage","提交成功", "好好学习,天天向上") \'生成成功提示页 .AddButton("btn1","继续测试","camera.htm") End With e.WriteString(wb.Build) e.Handled=True 老师我是用例子改的,现在的结果是提交白屏就完了,请老师指导下,确实搞不懂 |
-- 作者:有点蓝 -- 发布时间:2020/3/29 20:11:00 -- 最关键的是前端js是怎么提交文件的? |