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