设为首页
加入收藏
帮助中心
首页 | 红盾通告 | 信息中心 | ASP技术 | 数据库 | 网页设计 | 网管专栏 | OICQ攻略 | 墨客频道 | 网站运营 |
当前位置:首页 >> ASP技术 >> ASP应用 >> 正文
最新信息
·asp无限级分类加js收缩伸展…
·ASP读取EXCEL数据
·ASP编程操作Excel
·ASP编写了一个EXCEL上传程…
·ASP如何读取EXCEL工作表名…
·ASPJpeg和ASPUpload组件的…
·用ASP和SQL语句动态的创建…
·asp生成excel报表
·四大 FCKeditor 实战应用技…
·FCKeditor 2.0 的设置.修改…
资料搜索
热点信息
·asp生成excel报表
·Javascript+ASP制作树形菜…
·AspUpload组件的UploadedF…
·ASPJpeg和ASPUpload组件的…
·FckEditor中文配置手册详细…
·ASPUpload组件介绍
·金光ASP柱形图程序
·asp生成不重复的随机数字
·ASP读取EXCEL数据
·0-29内取15个不同的随机数…
推荐信息
·用ASP生成二维饼图
·一个取图片尺寸的类,支持…
·随即文件名
·ASP 随机图片
·本地图片,音乐等ASP防盗代…
·ASPJpeg和ASPUpload组件的…
·如何实现网上考试?
·用ASP打开远端MDB文件的方…
·ASP编写完整的一个IP所在地…
·用ASP实现远程批量文件改名


Google
 
AspUpload组件上传例子代码
〖作者:海娃 | 编辑:Cloudy | 浏览:人次〗

bar.asp

<%@EnableSessionState=False%>
<%
 Response.Expires = -1
 PID = Request("PID")
 TimeO = Request("to")
 Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
 format = "<br><CENTER><b>正在上传,请耐心等待...</b></CENTER><br>%T%t%B3%T 速度:(%S/秒)  估计剩余时间:%R %r%U / %V(%P)%l%t"
 bar_content = UploadProgress.FormatProgress(PID, TimeO, "#00007F", format)
 If "" = bar_content Then
%>
<HTML>
<HEAD>
<TITLE>Upload Finished</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function CloseMe()
{
 window.parent.close();
 return true;
}
</SCRIPT>
</HEAD>
<BODY OnLoad="CloseMe()" BGCOLOR="menu">
</BODY>
</HTML>
<%
 Else    '' Not finished yet
%>
<HTML>
<HEAD>
<meta HTTP-EQUIV="Refresh" CONTENT="1;URL=<%
Response.Write Request.ServerVariables("URL")
Response.Write "?to=" & TimeO & "&PID=" & PID %>">
<TITLE>Uploading Files...</TITLE>
<style type="text/css">
body,td {font-family:Tahoma; font-size: 8pt }
td.spread {font-size: 6pt; line-height:6pt }
td.brick {font-size:6pt; height:12px}
</style>
</HEAD>
<BODY BGCOLOR="menu" topmargin=0>
<% = bar_content %>
</BODY>
</HTML>
<% End If %>

fileconfig.asp

<%
Dim UploadFilePath,UploadLimitSize,NotAllowfileext,BrowerFilePath
UploadFilePath =  year(now)&"_"&month(now)&"_"&day(now)&"/"
''文件上传路径

BrowerFilePath =  "/"

UploadLimitSize = 1024*50 ''50M
''最大上传文件大小,单位为K

NotAllowfileext = "asp|cer|cdx|asa|htw|ida|idq|shtm|shtml|stm|printer|cgi|php|php4|cfm|aspx"
''不可以上传的文件类型

function CanUpload(Fileurl)
 Fileurl = lcase("|"& Mid(Fileurl, InstrRev(Fileurl, ".") + 1)& "|")
 NotAllowfileextstr = "|"&NotAllowfileext&"|"
 if instr(NotAllowfileextstr,Fileurl)>0 then
  CanUpload = false
 else
  CanUpload = true
 end if
end function

Function CreateFolder(Filepath)
 Dim fso, f
 on error resume next
 Set fso = CreateObject("Scripting.FileSystemObject")
 if not fso.FolderExists(Filepath) then
  Set f = fso.CreateFolder(Filepath)
  set f = Nothing
 end if
 set fso = Nothing
End Function
%>

framebar.asp

<%@EnableSessionState=False%>
<% Response.Expires = -1 %>
<title>正在上传............</title>
<style type=''text/css''>td {font-family:Tahoma; font-size: 8pt }</style>
<BODY BGCOLOR="menu" scroll="NO" frameborder="NO" status="no" style="border:0px;">
<script language="JavaScript">
<!--
function Stopupload()
{
 if (typeof(window.opener)!="undefined"){
  try{
   window.opener.document.execCommand("stop");
  }
  catch(e){}
 }
 else if(typeof(window.dialogArguments)!="undefined"){
  try{
   window.dialogArguments.document.execCommand("stop");
  }
  catch(e){}
 }
 window.close();
}
//-->
</script>
<IFRAME src="bar.asp?PID=<%= Request("PID") & "&to=" & Request("to") %>" title="Uploading" noresize scrolling=no
frameborder=0 framespacing=10 width=369 height=115></IFRAME>
<TABLE BORDER="0" WIDTH="100%" cellpadding="2" cellspacing="0">
 <TR><TD ALIGN="center"><button onclick="Stopupload()" style="font-size:12px;">取消上传</button>
</TD></TR>
</TABLE>
</BODY>
</HTML>

uploadfile.asp

<!--#include file=''fileconfig.asp''-->
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Keywords" content="51windows.Net">
<meta name="Author" content="haiwa">
<title>Upload -51windows.Net</title>
<style>
<!--
*         {font:12px;}
-->
</style>
</head>
<body>
<%
On Error Resume Next
Server.ScriptTimeOut=999999
if request("act")="upload" then
 dim folder,savepath
 savepath=Server.MapPath(UploadFilePath)
 CreateFolder(savepath)
 Set Upload=Server.CreateObject("Persits.Upload")
 Upload.SetMaxSize UploadLimitSize*1024, True
 Upload.OverwriteFiles = false
 if Request.QueryString("PID") = "" then
  Upload.ProgressID="010D60EB00C5AA4B"
 else
  Upload.ProgressID=Request.QueryString("PID")
 end if
 Count=Upload.Save(savepath)
 If Err.Number <> 0 Then
  Response.Write "<div style=""color:red;font-size:12px;"">出现错误: " & Err.Number & "、" & Err.Description &"<a href=""javascript:history.go(-1)"">重新上传</a></div>"
 End If
 If Err.Number = 8 Then
  Response.Write "<div style=""color:red;font-size:12px;"">你上传的文件超过限制("& UploadLimitSize/1024 &"M)<a href=""javascript:history.go(-1)"">重新上传</a></div>"
  response.end
 end if
 dim inputname
 dim size,rs_upfile
 For Each File in Upload.Files
  if not  CanUpload(File.ext) then
   File.Delete
   response.write "<div style=""color:red;font-size:12px;"">"&file.filename &"("& file.size &") 格式不正确!<a href=""javascript:history.go(-1)"">重新上传</a></div>"
  else
   response.write "<div style=""color:green;font-size:12px;""><!-- "&file.filename &"("& file.size &") --> 上传成功"%><a href="javascript:history.go(-1)">重新上传</a></div><%
  end if
 next
else
%>
<%
dim SPid,PID,barref
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
SPid = UploadProgress.CreateProgressID()
PID = "PID=" & SPid
barref = "framebar.asp?to=10&" & PID
%>
<SCRIPT LANGUAGE="JavaScript">
function ShowProgress()
{
 strAppVersion = navigator.appVersion;
 if (document.MyForm.FILE1.value != "")
 {
   if (strAppVersion.indexOf(''MSIE'') != -1 && strAppVersion.substr(strAppVersion.indexOf(''MSIE'')+5,1) > 4)
   {
     winstyle = "dialogWidth=375px; dialogHeight:175px; center:yes;status:no";
     window.showModelessDialog(''<% = barref %>&b=IE'',window,winstyle);
   }
   else
   {
     window.open(''<% = barref %>&b=NN'','''',''width=370,height=165'', true);
   }
 }
 return true;
}
function chk()
{
 if (MyForm.FILE1.value=="")
 {
  alert("请从硬盘选择你要上传的文件...");
  return false;
 }
}
</SCRIPT>
<FORM NAME="MyForm" method="post" ENCTYPE="multipart/form-data" ACTION="?<% = PID %>&act=upload" OnSubmit="return ShowProgress();">
<INPUT NAME="FILE1" TYPE="FILE" SIZE="16"> <input name="Submit" type="submit" value="上 传" onclick="return chk()"></FORM>
<%end if%>
</body>
</html>


录入时间:2006-11-01 12:44:27 [打印本页] [关闭窗口] [返回顶部]
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

Copyright © 2006-2014 0733168.Com Inc All Rights Reserved
关于我们 | 广告合作 | 联系我们 | 法律声明 | 友情链接 | 意见反馈
本站所收录信息、社区话题、及本站所做之广告均属其个人行为,与本站立场无关
湘ICP备06008436号