-- 作者:宝宝猪jerry
-- 发布时间:2020/8/25 18:28:00
-- 【求助】老师,Post可以接收数据,但是图片怎么也接收不了,帮忙看看哪里出问题了?
Dim wb As New weui \'身份验证 Dim Verified As Boolean \'用于标记用户是否通过了身份验证 Dim UserName As String = e.Cookies("username") \'从cookie中获取用户名 Dim Password As String = e.Cookies("password") \'从cookie中获取用户密码 If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码 If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") Then UserName = e.PostValues("username") Password = e.PostValues("password") End If End If Dim dr As DataRow dr = DataTables("users").Find("user_code = \'" & UserName & "\'") If dr IsNot Nothing AndAlso dr("Password").contains(password) Then Verified = True End If If Verified AndAlso e.Path = "logon.htm" Then \'如果用户访问的是登录页,且身份验证成功 wb.AppendCookie("username",UserName) \'将用户名和密码写入cookie wb.AppendCookie("password",Password) wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'直接跳转到首页 e.WriteString(wb.Build) \'生成网页 Return \'必须的 ElseIf Verified = False AndAlso e.Path <> "logon.htm" Then \'如果用户身份验证失败,且访问的不是登录页面 wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面 e.WriteString(wb.Build) \'生成网页 Return \'必须的 End If \'开始生成网页 Select Case e.path Case "logon.htm" \'登录页面 wb.AddPageTitle("","pageheader","GRAsystem-Web","普研(上海)标准技术服务股份有限公司") If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") Then \'判断是否是验证失败后的重新登录 wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 \'如果用户通过登录按钮访问,则给用户一个2秒的提示. End If wb.AddForm("","form1","logon.htm") With wb.AddInputGroup("form1","ipg1") .AddInput("username","用户","text") .AddInput("password","密码","password") End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "登录", "submit") End With With wb.AddPageFooter("","pf1","GRA-Web ? 2020 gratech.com.cn") .AddLink("普研(上海)标准技术服务股份有限公司","http://www.gratech.com.cn") End With Case "exit.htm" \'退出登录 wb.DeleteCookie("username") \'清除cookie中原来的用户名和密码 wb.DeleteCookie("password") wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面 Case "", "default.htm" \'首页 wb.AddPageTitle("","pageheader","GRAsystem-Web","普研(上海)标准技术服务股份有限公司") With wb.AddGrid("","g1") .Add("c1","采样日志", "./images/cy.png","Caiyang.htm") \'.Add("c2","项目查询", "./images/cell.png").Attribute = "" \'.Add("c3","项目审批", "./images/toast.png").Attribute = "" \'.Add("c4","Lims主页", "./images/dialog.png", "http://www.gratech.com.cn/") .Add("c5","退出", "./images/exit.png", "exit.htm") \'退出登录 End With With wb.AddPageFooter("","pf1","GRA-Web ? 2020 gratech.com.cn") .AddLink("普研(上海)标准技术服务股份有限公司","http://www.gratech.com.cn") End With Case "Caiyang.htm" \'采样页面 Dim sb As New StringBuilder wb.AddPageTitle("","form2","采样日志","") wb.AddToast("","t1", "正在上传",1) \'定义提示 With wb.AddForm("","form3","handle.htm") .attribute= """ End With With wb.AddInputGroup("form3","Caiyang","") .AddInput("sp_name","客户/项目名:","text").PlaceHolder= "请输入客户或项目名称全称(必填)" .AddInput("batch_m","批次:","number").PlaceHolder= "请输入数字(必填)" .AddSelect("batch_h","抽样环节:","流通|餐饮|生产|其他") With .AddInput("fy_sample","采样样品费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With .AddInput("prove_n","未抽到证明:","number").PlaceHolder= "请输入数字(必填)" .AddSelect("use_car","用车情况:","公司车辆|私车公用|外租车辆|公共交通") .AddInput("driver","车辆驾驶员:","text").PlaceHolder= "非公司车辆填【无】(必填)" With .AddInput("fy_zl","租赁费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With With .AddInput("fy_ry","燃油费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With With .AddInput("fy_gs","高速费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With With .AddInput("fy_sample","采样样品费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With With .AddInput("fy_tc","停车费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With With .AddInput("fy_kd","快递费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With With .AddInput("fy_qy","取样费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With With .AddInput("fy_cl","住宿差旅费:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With With .AddInput("fyt_other","其他费用:","number") .PlaceHolder= "请输入数字(必填)" .Step = "0.01" End With .AddSwitch("ycy","是否夜抽") .AddSwitch("wdcy","是否外地采样") .AddInput("sxr1","随行人员","text").PlaceHolder= "请填写姓名(选填)" .AddInput("sxr2","随行人员","text").PlaceHolder= "请填写姓名(选填)" .AddInput("remake","备注","text").PlaceHolder= "(选填)" .AddUploader("pic","图片",True) End With With wb.AddButtonGroup("form3","btg1",True) .Add("btn1", "确定", "submit") .Add("btn2","返回主页","button","default.htm") End With Case "handle.htm" Dim nms() As String = {"sp_name","batch_m","batch_h","fy_sample","prove_n","use_car","driver","fy_zl","fy_ry","fy_gs","fy_tc","fy_kd","fy_qy","fyt_other","fy_cl"} Dim rms() As String = {"remake","sxr1","sxr2","ycy","wdcy"} For Each nm As String In nms If e.PostValues.ContainsKey(nm) = False Then e.WriteString("请输入" & nm & "!") \'返回错误消息 Return \'必须返回 End If Next Dim lx As DataRow = DataTables("cy_data").AddNew() lx("userid")= UserName For Each nm As String In nms lx(nm) = e.PostValues(nm) Next For Each rm As String In rms lx(rm) = e.PostValues(rm) Next For Each key As String In e.Files.Keys If key = "pic" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "C:\\GRAsystem\\Attachment\\Web\\CYpic\\" & fln) Next lx.Lines("pic") = e.Files(key) End If Next lx.Save() With wb.AddMsgPage("","msgpage","增加成功", "") \'生成成功提示页 .AddButton("btn1","继续增加","Caiyang.htm") .AddButton("btn2","返回主页","default.htm") End With End Select e.WriteString(wb.Build) \'生成网页 此主题相关图片如下:{f90ab818-0ca7-4bb0-9350-bac04f0fdfdc}_20200825182904.jpg
[此贴子已经被作者于2020/8/25 18:31:04编辑过]
|