以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 图片上传失败 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=98842) |
|
-- 作者:zhangjian222200 -- 发布时间:2017/4/7 22:11:00 -- 图片上传失败 Dim e As RequestEventArgs = args(0) \'注册第7页,上传照片 Select Case e.Path Case "images.htm" Dim wb As New weui If e.PostValues.Count = 0 Then wb.AddTopTips("","toptip1","") \'用于显示动态错误提示 \'wb.AddPageTitle("","pageheader","***","*********") With wb.AddArticle("","ar1") .AddImage("./images/langwo/logo1.jpg") .Attribute = "style=\'padding:0em;\'" End With wb.AddForm("","form1","valid_images.htm").Attri-bute="on-submit=\'re-turn validit_images()\'" With wb.AddInputGroup("form1","ipg1","展示照(选择1张靓照即可)") \'文件上传(1个) .AddUploader("up1","",False) End With With wb.AddInputGroup("form1","ipg22","生活照(选择4张以上靓照)") \'带图片浏览的文件上传(最少4个) With.AddUploader("up4","",True) \'True表示允许一次上传多个文件 .AllowDelete = True \'允许删除 .Incremental = True \'允许 重复选择文件或连续拍照 End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "提交", "submit") \'.Attri-bute= "on-click=\'sub-mitForm()\'" \'调用js函数上传 End With wb.AddToast("","tst1", "正在上传",1) wb.AddToast("","tst2", "上传成功",0) wb.AddToast("","tst3", "上传失败",0).Icon= "warn" wb.AppendHTML("<script src=\'./lib/ajaxform_images.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 End If End Select 下面的代码保存图片,图片数量验证正常,上传没有成功,没有任何提示 Dim e As RequestEventArgs = args(0) \'验证页面(照片) Select Case e.Path Case "valid_images.htm" Dim wb As New weui Dim drbianh As String = e.Cookies("drbianhao") \'为cookie传递数据 Dim NewName As String msgbox(drbianh) Dim dr As DataRow = DataTables("会员资料").sqlFind("会员编号 = \'" & drbianh & "\'") If dr IsNot Nothing Then \'测试代码:msgbox(e.PostValues("isr")) For Each key As String In e.Files.Keys If key = "up1" Then For Each fln As String In e.Files(key) msgbox(0) Dim ext As String = fln.Split(".")(1) NewName = Format(Date.Now, "yyyyMMddHHmmssffffff") & Rand.Next(10000) & "." & ext e.SaveFile(key, fln, ProjectPath & "Attachments\\" & NewName) dr("展示照") &= iif(dr.IsNull("展示照"), "", vbcrlf) & NewName Next End If Next For Each key1 As String In e.Files.Keys If key1 = "up4" Then For Each fln1 As String In e.Files(key1) msgbox(1) Dim ext1 As String = fln1.Split(".")(1) NewName = Format(Date.Now, "yyyyMMddHHmmssffffff") & Rand.Next(10000) & "." & ext1 e.SaveFile(key1, fln1, ProjectPath & "Attachments\\" & NewName) dr("生活照") &= iif(dr.IsNull("生活照"), "", vbcrlf) & NewName Next End If Next dr.save() \'保存 End If wb.InsertHTML("<meta http-equiv=\'Re-fresh\' con-tent=\'0; u-rl=/success.htm\'>") \'那么直接跳转到登录页面 e.WriteString(wb.Build) \'生成网页 End Select [此贴子已经被作者于2017/4/7 22:40:07编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2017/4/7 22:20:00 -- 调试运行到哪一句代码? |
|
-- 作者:zhangjian222200 -- 发布时间:2017/4/7 22:42:00 -- 1楼valid_images.htm代码,加了3处msgbox(粉色),执行,验证正常,但是3处,均无提示,居然没有一个执行的 images.htm里面的那个form,信息已经提交到valid_images.htm的啊,咋会不执行 wb.AddForm("","form1","valid_images.htm").Attri-bute="on-submit=\'re-turn validit_images()\'"
[此贴子已经被作者于2017/4/7 22:44:51编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2017/4/7 22:55:00 -- Attri-bute="on-submit=\'re-turn validit_images()\'" 上面的js函数有没有返回true valid_images.htm各处名称能否对应上,正常HttpRequest如果已经case判断过,函数里就没有必要使用select case再判断一次了
|
|
-- 作者:zhangjian222200 -- 发布时间:2017/4/7 23:00:00 -- 这是js文件: 1.数量不对,可以正常提示,我上传的时候,数量都是对的, 2.js代码我加了粉色alert,第二处不能提示(第一个提示正常) function validit_images(){ var v1 = document.getElementById("up1_thumbnails").getElementsByTagName("li").length; var v2 = document.getElementById("up4_thumbnails").getElementsByTagName("li").length; alert(v1 + " " + v2); if(v1 < 1){ showTopTips("toptip1","请选择1张展示照上传",2000); return false; } if(v2 < 4){ showTopTips("toptip1","请选择4张以上生活照上传",2000); return false; } return true; alert(v2); } 这是httprequest事件跳转代码,核对是正确的
[此贴子已经被作者于2017/4/7 23:15:36编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2017/4/7 23:14:00 -- http://www.foxtable.com/mobilehelp/scr/0106.htm 如果我们将Uploader的Incremental属性设置为True,可以实现: 1、再次选择上传文件,不会覆盖之前上传的文件。 但是,在这种情况下,表单默认的提交功能,将不会上传选择好的文件,我们只能用submitAjaxForm函数提交表单,不过代码依旧很简单。 |
|
-- 作者:zhangjian222200 -- 发布时间:2017/4/7 23:17:00 -- 在你6楼刚发布时 我测试了下,js代码好像有点问题,js应该不返回true,写在5楼了
[此贴子已经被作者于2017/4/7 23:18:48编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2017/4/7 23:19:00 -- 问题看6楼 return之后的任何代码都不会执行的
|
|
-- 作者:zhangjian222200 -- 发布时间:2017/4/7 23:28:00 -- 麻烦看看思路,对否(首先,js验证成功,再调用submitForm()提示上传,进入了一个页面上传照片) 111 function validit_images(){ var v1 = document.getElementById("up1_thumbnails").getElementsByTagName("li").length; var v2 = document.getElementById("up4_thumbnails").getElementsByTagName("li").length; alert(v1 + " " + v2); if(v1 < 1){ showTopTips("toptip1","请选择1张展示照上传",2000); return false; } if(v2 < 4){ showTopTips("toptip1","请选择4张以上生活照上传",2000); return false; } //return true; 这句可以不要了 } 在images.htm代码里调用submitForm()
[此贴子已经被作者于2017/4/7 23:53:41编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2017/4/8 8:54:00 -- 1、js代码: Function validit_images(){ var v1 = document.getElementById("up1_thumbnails").getElementsByTagName("li").length; var v2 = document.getElementById("up4_thumbnails").getElementsByTagName("li").length; alert(v1 + " " + v2); If(v1 < 1){ showTopTips("toptip1","请选择1张展示照上传",2000); Return false; } If(v2 < 4){ showTopTips("toptip1","请选择4张以上生活照上传",2000); Return false; } show("tst1",2000); var result = submitAjaxForm(\'form1\',\'afterSubmit\'); } Function afterSubmit(result){ hide("tst1"); If (result==\'OK\') { show("tst2"); location="success.htm"; } Else{ show("tst3",2000); } } 2、 Dim e As RequestEventArgs = args(0) \'注册第7页,上传照片 Select Case e.Path Case "images.htm" Dim wb As New weui If e.PostValues.Count = 0 Then wb.AddTopTips("","toptip1","") \'用于显示动态错误提示 \'wb.AddPageTitle("","pageheader","***","*********") With wb.AddArticle("","ar1") .AddImage("./images/langwo/logo1.jpg") .Attribute = "style=\'padding:0em;\'" End With wb.AddForm("","form1","valid_images.htm") With wb.AddInputGroup("form1","ipg1","展示照(选择1张靓照即可)") \'文件上传(1个) .AddUploader("up1","",False) End With With wb.AddInputGroup("form1","ipg22","生活照(选择4张以上靓照)") \'带图片浏览的文件上传(最少4个) With.AddUploader("up4","",True) \'True表示允许一次上传多个文件 .AllowDelete = True \'允许删除 .Incremental = True \'允许 重复选择文件或连续拍照 End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "提交", "button").Attribute= "onclick=\' validit_images()\'" \'调用js函数上传 End With wb.AddToast("","tst1", "正在上传",1) wb.AddToast("","tst2", "上传成功",0) wb.AddToast("","tst3", "上传失败",0).Icon= "warn" wb.AppendHTML("<script src=\'./lib/ajaxform_images.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 End If End Select 下面的代码保存图片,图片数量验证正常,上传没有成功,没有任何提示 Dim e As RequestEventArgs = args(0) \'验证页面(照片) Select Case e.Path Case "valid_images.htm" Dim wb As New weui Dim drbianh As String = e.Cookies("drbianhao") \'为cookie传递数据 Dim NewName As String msgbox(drbianh) Dim dr As DataRow = DataTables("会员资料").sqlFind("会员编号 = \'" & drbianh & "\'") If dr IsNot Nothing Then \'测试代码:msgbox(e.PostValues("isr")) For Each key As String In e.Files.Keys If key = "up1" Then For Each fln As String In e.Files(key) msgbox(0) Dim ext As String = fln.Split(".")(1) NewName = Format(Date.Now, "yyyyMMddHHmmssffffff") & Rand.Next(10000) & "." & ext e.SaveFile(key, fln, ProjectPath & "Attachments\\" & NewName) dr("展示照") &= iif(dr.IsNull("展示照"), "", vbcrlf) & NewName Next End If Next For Each key1 As String In e.Files.Keys If key1 = "up4" Then For Each fln1 As String In e.Files(key1) msgbox(1) Dim ext1 As String = fln1.Split(".")(1) NewName = Format(Date.Now, "yyyyMMddHHmmssffffff") & Rand.Next(10000) & "." & ext1 e.SaveFile(key1, fln1, ProjectPath & "Attachments\\" & NewName) dr("生活照") &= iif(dr.IsNull("生活照"), "", vbcrlf) & NewName Next End If Next dr.save() \'保存 e.WriteString("OK") \'生成网页 Else e.WriteString("错误提示") End If End Select [此贴子已经被作者于2017/4/8 8:55:54编辑过]
|