以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  上传文件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=157710)

--  作者:lshshlxsh
--  发布时间:2020/10/26 15:57:00
--  上传文件

请问老师 在上传图片前 怎么判断是否有图片才能上传?


Select Case e.Path
    Case "upload.htm"
        Dim wb As New weui
        wb.AddForm("","form1","receive.htm")
        With wb.AddInputGroup("form1","ipg1",
"
文件上传")
            With .AddUploader("up128",
"
照片",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.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\\" & fln)
\'
保存接收到的文件
            Next
        Next
        e.WriteString("OK")

End
Select


--  作者:有点蓝
--  发布时间:2020/10/26 16:06:00
--  
    Case "receive.htm"
if e.Files.Keys.count > 0 then
        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\\" & fln) 
\'
保存接收到的文件
            Next
        Next
        e.WriteString("OK")
else
e.WriteString("请添加文件!")
end if
End
 Select

js

function afterSubmit(result){
    hide("tst1");
    if (result==\'OK\') {
        show("tst2");
        location="upload.htm";
    }
    else{
alert(result);
        show("tst3",2000);
    }
}