以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 移动开发上传压缩图片 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=98455) |
-- 作者:bobolan521 -- 发布时间:2017/3/30 10:45:00 -- 移动开发上传压缩图片 http://www.foxtable.com/mobilehelp/index.htm?page=0060.htm 请问一下帮助里的例子如果要压缩图片,必须用JS代码吗? 上传图片例子里,加了几句红色代码,为什么实现不了上传压缩图片了 Dim fl As String = "d:\\web\\" & e.path If filesys.FileExists(fl) Dim idx As Integer = fl.LastIndexOf(".") Dim ext As String = fl.SubString(idx) Select Case ext Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar" e.WriteFile(fl) Return \'这里必须返回 End Select End If Dim wb As New weui Select Case e.Path Case "addnew.htm" If e.PostValues.Count = 0 Then wb.AddForm("","form1","addnew.htm") With wb.AddInputGroup("form1","ipg1","增加员工") .AddInput("姓名","姓名","Text") \'前一个"姓名"是ID,后一个"姓名"是标题 .AddInput("年龄","年龄","number") .AddSelect("学历","学历","大专|本科|硕士|博士") With .AddUploader("up128","照片",True) .AllowDelete = True \'允许删除 .Incremental = True \'允许重复选择文件或连续拍照 .ScaleWidth = 400 \'自动压缩图片宽度为400个像素,高度等比例压缩 End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "确定", "submit") End With e.WriteString(wb.Build) Else Dim nms() As String = {"姓名","年龄","学历"} Dim dr As DataRow = DataTables("员工").AddNew() For Each nm As String In nms dr(nm) = e.PostValues(nm) Next For Each key As String In e.Files.Keys If key = "up128" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("照片") = e.Files(key) End If Next \'保存并生成增加成功提示页面 dr.save() With wb.AddMsgPage("","msgpage","增加成功", "好好学习,天天向上") \'生成成功提示页 .AddButton("btn1","继续增加","addnew.htm") End With e.WriteString(wb.Build) End If End Select [此贴子已经被作者于2017/3/30 10:49:16编辑过]
|
-- 作者:有点蓝 -- 发布时间:2017/3/30 11:19:00 -- 是不是最新的weui库?http://www.foxtable.com/mobilehelp/scr/0011.htm |
-- 作者:bobolan521 -- 发布时间:2017/3/30 12:12:00 -- 老师是最新的weui库,是不是代码有问题啊 |
-- 作者:有点色 -- 发布时间:2017/3/30 12:27:00 -- 必须异步提交
http://www.foxtable.com/mobilehelp/scr/0251.htm
要实现图片的压缩上传,单单设置ScaleWidth或ScaleHeight是不够的,我们还需要将Uploader的Incremental属性设置为True,所以和上一节一样,我们只能用submitAjaxForm函数提交表单,不过代码依旧很简单。
|