以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- cookie 不起作用的? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=102596) |
||||
-- 作者:xietan417 -- 发布时间:2017/6/22 17:38:00 -- cookie 不起作用的? 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 Dim xm As String If e.Cookies.ContainsKey("xm") \'如果存在名为count的Cookie xm = e.Cookies("xm") \'从cookie中获取用户名 End If Select Case e.Path Case "upload.htm" wb.AddForm("","form1","receive.htm") With wb.AddRadioGroup("form1","wz","上传选择") .Add("保税仓","保税仓",True) .Add("普通仓","普通仓") \'默认勾选 End With With wb.AddInputGroup("form1","ipg1","永得利照片上传") With .AddInput("xm","上传人","text") .Value = xm End With With .AddUploader("up128","注意:只能传照片",True) .AllowDelete = True \'允许删除 .Incremental = True \'允许重复选择文件或连续拍照 .ScaleWidth = 800 \'自动压缩图片宽度为800个像素,高度等比例压缩 End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "确定", "button").Attribute= "" \'调用js函数上传 End With wb.AddToast("","tst1", "正在上传",1) wb.AddToast("","tst2", "上传成功",0) wb.AddToast("","tst3", "上传失败",0).Icon= "warn" wb.AppendHTML("<script src=\'./lib/ajaxform.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 Case "receive.htm" For Each key As String In e.Files.Keys For Each fln As String In e.Files(key) e.SaveFile(key,fln,"d:\\web\\uploadfiles\\" & e.PostValues("wz") &"\\"& fln) \'保存接收到的文件 Next Next e.WriteString("OK") If e.PostValues("xm") <> "" Then wb.AppendCookie("xm",e.PostValues("xm")) \'将用户名和密码写入cookie e.WriteString(wb.Build) \'生成网页 Return \'必须的 Else e.WriteString(wb.build) End If End Select
|
||||
-- 作者:有点色 -- 发布时间:2017/6/22 17:59:00 -- 改成这样即可
e.cookies.add("xm",e.PostValues("xm")) |
||||
-- 作者:xietan417 -- 发布时间:2017/6/23 1:16:00 -- 确定以后上传人那里还是空的!是我的代码出了问题吗? |
||||
-- 作者:有点蓝 -- 发布时间:2017/6/23 8:54:00 -- 在ajex里调用的页面设置Cookie是没有用的。 1、可以使用静态变量 2、在js里设置Cookie,如: Case "receive.htm" For Each key As String In e.Files.Keys For Each fln As String In e.Files(key) e.SaveFile(key,fln,"d:\\web\\uploadfiles\\" & e.PostValues("wz") &"\\"& fln) \'保存接收到的文件 Next Next e.WriteString("OK|xm|" & e.PostValues("xm")) js代码 function setCodes(){ var result= submitAjaxFileds(\'getCodes.htm\',\'\',\'province\',\'county\',false); if(result){ var vals=result.split("|"); if(vals.length==3 && vals[0] == \'OK\'){ document.cookie = vals[1] + \'=\' + vals[2] + \';expires=60000\' } } } |
||||
-- 作者:xietan417 -- 发布时间:2017/6/23 10:01:00 -- 怎么去调取JS呢?这方面不是太懂! |
||||
-- 作者:有点蓝 -- 发布时间:2017/6/23 10:29:00 -- 看4楼,例子看不懂。就请上传实例 |
||||
-- 作者:xietan417 -- 发布时间:2017/6/23 10:39:00 -- 还有就是如何去判断没有选择上传图片时,不能点确定上传?
|
||||
-- 作者:有点蓝 -- 发布时间:2017/6/23 11:01:00 -- 请上传js文件ajaxform.js |
||||
-- 作者:xietan417 -- 发布时间:2017/6/23 11:17:00 -- function submitWithProgress(){ var result = submitAjaxForm(\'form1\',\'afterSubmit\',true,\'tst1\'); } function afterSubmit(result){ hide("tst1"); if (result==\'OK\') { show("tst2"); location="upload.htm?v="+Math.random(); } else{ show("tst3",2000); } } 不给上传JS文件哦
|
||||
-- 作者:有点蓝 -- 发布时间:2017/6/23 12:08:00 -- 1、代码这个case Case "receive.htm" For Each key As String In e.Files.Keys For Each fln As String In e.Files(key) e.SaveFile(key,fln,"d:\\web\\uploadfiles\\" & e.PostValues("wz") &"\\"& fln) \'保存接收到的文件 Next Next e.WriteString("OK|xm|" & e.PostValues("xm")) 2、js function afterSubmit(result){ hide("tst1"); if(result){ var vals=result.split("|"); if(vals.length==3 && vals[0] == \'OK\'){ show("tst2"); document.cookie = vals[1] + \'=\' + vals[2] + \';expires=600000\' location="upload.htm?v="+Math.random(); } else{ show("tst3",2000); } } |