当前位置: 移动技术网 > IT编程>开发语言>.net > ASP无组件上载,带进度条,多文件上载

ASP无组件上载,带进度条,多文件上载

2018年10月09日  | 移动技术网IT编程  | 我要评论

张家宁,正在播放,美吉姆邮箱

example.

<%@language="vbscript" codepage="65001"%>
<!--#include file="sundyupload.asp"-->
<%
此例子文档编码都是utf-8,如果是其他编码的,请将编码转换为相应的编码,不然表单获取数据可能会乱码
dim objupload,opt
dim xml(标准化越来越近了)path
dim fileformname,objfile,counter
opt = request.querystring("opt")
if opt = "upload" then
  xml(标准化越来越近了)path = server.mappath(request.querystring("xml(标准化越来越近了)path"))将虚拟路径转换为实际路径
    set objupload=new sundyupload 建立上传对象
    objupload.uploadinit xml(标准化越来越近了)path,"utf-8"
    counter = 1
    response.write("普通表单:" & objupload.form("normalform") & "<br><br>")获取表单数据
    for each fileformname in objupload.objfile
      set objfile=objupload.objfile(fileformname)
        filesize = objfile.filesize
  strtemp= objfile.filepath
  response.write strtemp
  filename = mid(strtemp,instrrev(strtemp, "")+1)
        if filesize > 0 then
            response.write("file size:" & filesize & "<br>")
            response.write("file name:" & objfile.filepath  & "<br>")
           response.write("file description:" & objupload.form("filedesc" & counter) & "<br><br>")
           objfile.saveas server.mappath(".") & "upload" & filename
   response.write "save at: "&server.mappath(".") & "upload" & filename & "<br><br>"
        end if
        counter = counter + 1
    next
   
end if
为上载进度条数据文件(xml(标准化越来越近了)文件指定虚拟路径)
最好是随机的,因为可能多个人同时上载,需要不同的进度数据
这个路径需要在提交的时候传入上载中,以便在上载过程中更改进度数据
客户端使用javascript来读取此xml(标准化越来越近了)文件,显示进度
xml(标准化越来越近了)path = "upload/" & timer & ".xml(标准化越来越近了)"
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>sundy upload progress bar example</title>
<script language="javascript">
function chkfrm(){
  var objfrm = document.frmupload;
    if (objfrm.file1.value=="" && objfrm.file2.value==""){
      alert("请选择一个文件");
        objfrm.file1.focus();
        return false;
    }
    objfrm.action = "example.asp?opt=upload&xml(标准化越来越近了)path=<%=xml(标准化越来越近了)path%>";
    startprogress(<%=xml(标准化越来越近了)path%>);//启动进度条
    return true;
}
</script>
</head>

<body>
<form name="frmupload" method="post" action="example.asp" enctype="multipart/form-data" onsubmit="return chkfrm()">
普通表单:<br><input type="text" name="normalform" size="40"><br><br>
文件1:<br>
<input type="file" name="file1" size="40"></br>
<input type="text" name="filedesc1" size="30"><br><br>
文件2:<br>
<input type="file" name="file2" size="40"></br>
<input type="text" name="filedesc2" size="30"><br>
文件3:<br>
<input type="file" name="file3" size="40"></br>
文件4:<br>
<input type="file" name="file4" size="40"></br>
文件5:<br>
<input type="file" name="file5" size="40"></br>
<input type="submit" name="btnsubmit" value="submit"/>
</form>
</body>
</html>

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网