以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何禁止上传".wmf",".js",".css" ,".html",".htm",".zip",".rar" 文件 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=105480) |
|
-- 作者:zhangjian222200 -- 发布时间:2017/8/20 18:07:00 -- 如何禁止上传".wmf",".js",".css" ,".html",".htm",".zip",".rar" 文件 如何禁止上传".wmf",".js",".css" ,".html",".htm",".zip",".rar" 文件 居然还有人上传成功.exe后缀名图片
Dim e As RequestEventArgs = args(0) \'注册第7页,上传照片 Dim wb As New weui wb.AddTopTips("","toptip1","") \'用于显示动态错误提示 wb.AddForm("","form1","valid_images.htm") With wb.AddInputGroup("form1","ipg1","展示照(选择1张靓照即可)") \'文件上传(1个) With.AddUploader("up1","",False) .AllowDelete = True \'允许用户删除图片 .ScaleWidth = 400 \'自动压缩图片宽度为400个像素,高度等比例压缩 End With End With With wb.AddInputGroup("form1","ipg22","生活照(选择3张以上靓照)") \'带图片浏览的文件上传(最少4个) With.AddUploader("up4","",True) \'True表示允许一次上传多个文件 .AllowDelete = True \'允许删除 .Incremental = True \'允许 重复选择文件或连续拍照 .ScaleWidth = 400 \'自动压缩图片宽度为400个像素,高度等比例压缩 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_images.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 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(v1 > 1){ showTopTips("toptip1","展示照只可以上传1张!",2000); return false; } if(v2 < 3){ showTopTips("toptip1","请选择3张以上生活照上传!",2000); return false; } if(v2 > 9){ showTopTips("toptip1","生活照最多可以上传9张!",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); } } [此贴子已经被作者于2017/8/20 18:21:29编辑过]
|
|
-- 作者:有点甜 -- 发布时间:2017/8/20 18:26:00 -- 方法一:在你httprequest事件处理,判断上传的文件名,根据后缀名判断,最后你保存的时候,不是自由控制么?
方法二:在js里面直接判断,foxtable的weui.me.js已经做了判断的啊 previewFile 函数 |
|
-- 作者:zhangjian222200 -- 发布时间:2017/8/20 18:48: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); var ary1 = document.getElementById("up1_thumbnails").split(".") var ary4 = document.getElementById("up4_thumbnails").split(".") if(ary1[1] <> \'jpg\' or ary1[1] <> \'jpeg\' or ary1[1] <> \'png\' or ary1[1] <> \'gif\' or ary1[1] <> \'bmp\'){ showTopTips("toptip1","请上传正确的文件格式!",2000); return false; } if(ary4[1] <> \'jpg\' or ary4[1] <> \'jpeg\' or ary4[1] <> \'png\' or ary4[1] <> \'gif\' or ary4[1] <> \'bmp\'){ showTopTips("toptip1","请上传正确的文件格式!",2000); return false; } if(v1 < 1){ showTopTips("toptip1","请选择1张展示照上传!",2000); return false; } if(v1 > 1){ showTopTips("toptip1","展示照只可以上传1张!",2000); return false; } if(v2 < 3){ showTopTips("toptip1","请选择3张以上生活照上传!",2000); return false; } if(v2 > 9){ showTopTips("toptip1","生活照最多可以上传9张!",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); } }
|
|
-- 作者:有点甜 -- 发布时间:2017/8/20 19:39:00 -- var frm = document.getElementById("form1"); |
|
-- 作者:zhangjian222200 -- 发布时间:2017/8/20 21:14: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); var frm = document.getElementById("form1"); var frmdata = new FormData(frm); if (frm.incremental) { var fluds = frm.getElementsByClassName("weui_uploader_input"); for (var idx = 0; idx < fluds.length; idx++) { var files = fluds[idx].Files; if (files) { for (var i = 0; i < files.length; i++) { alert(files[i].blobFile); var fln = files[i].blobFile if (typeof(fln) == "undefined") { alert("文件格式不正确"); return false; } fln = fln.substring(fln.lastIndexOf(".") + 1).toLowerCase(); switch (fln) { case "jpg": case "jpeg": case "png": case "gif": case "bmp": case "wmf": break; } } } } } if(v1 < 1){ showTopTips("toptip1","请选择1张展示照上传!",2000); return false; } if(v1 > 1){ showTopTips("toptip1","展示照只可以上传1张!",2000); return false; } if(v2 < 3){ showTopTips("toptip1","请选择3张以上生活照上传!",2000); return false; } if(v2 > 9){ showTopTips("toptip1","生活照最多可以上传9张!",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); } }
|
|
-- 作者:有点甜 -- 发布时间:2017/8/20 21:32:00 -- 我测试没问题。 |
|
-- 作者:zhangjian222200 -- 发布时间:2017/8/20 22:10:00 --
|
|
-- 作者:有点甜 -- 发布时间:2017/8/20 22:16:00 -- var frm = document.getElementById("form1"); break; default: alert("格式错误"); return false; |