最近闲来无事,给公司做了个内部娱乐网站(ASP的),用的服务器是win2003+IIS6.0,因为是内部的,足够用了。其中一个功能是在线影院,提供在线观看、下载功能,同时也提供上传功能。

在上传大文件时,稍微费了些时间。

1.首先要修改 metabase.xml 文件,因为IIS6.0默认上传限制是20K。

首先停止Internet 信息服务(IIS)的internet服务;

找到文件c:/windows/system32/inetsrv/metabase.xml,用“记事本”打开该文件,修改AspMaxRequestEntityAllowed。

好像IIS最大支持的也就1G吧,因为尝试把这个值设的非常大时,这个属性就会在文件中消失。

2.  下载安装Aspupload

3.  为了防止上传超时,在程序里要加上这么一句: Server.ScriptTimeout=9999

4.   下面就是代码了:

(1) 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 %>

(2)  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
%>

(3) 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 οnclick="Stopupload()" style="font-size:12px;">取消上传</button>
</TD></TR>
</TABLE>
</BODY>
</HTML>

(4)  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
dim NewName
NewName = year(now) & "-" & month(now) & "-" & day(now) & "-" & hour(now) & "-" & minute(now) & "-" & second(now) & File.ext
File.Move savepath & "/" & NewName
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="上 传" οnclick="return chk()"></FORM>
<%end if%>
</body>
</html>

这样,访问uploadfile.asp,就能实现上传了。

AspUpload组件上传大文件相关推荐

  1. asp.net 上传大文件解决方案(转)

    这次在项目中,用到了大文件上传,要上传的文件有100多m,于是研究现在国内使用的大文件上传的 组件发现用的比较多的有两个控件AspnetUpload 2.0和Lion.Web.UpLoadModule ...

  2. PHP上传大文件 分割文件上传

    PHP上传大文件 分割文件上传 PHP上传大文件 分割文件上传 作者:Eamonn 发布时间:2012-03-24 14:49 访问:523 分类:PHP & Mysql 最近遇到这么个情况, ...

  3. vue上传大文件/视频前后端(java)代码

    vue上传大文件/视频前后端(java)代码 一.上传组件 二.后端java代码 注意: 一.上传组件 <template><div><!-- 上传组件 -->&l ...

  4. Asp.Net 上传大文件专题(4)--利用ajax技术显示上传进度

    ====================================================== 注:本文源代码点此下载 ================================= ...

  5. ssm上传文件进度条_SSM框架+Plupload实现分块上传大文件示例

    关于Plupload的介绍,相信它的官网http://www.plupload.com/已经给得很详细了.Plupload的上传原理简单点说,就是将用户选中的文件(可多个)分隔成一个个小块,依次向服务 ...

  6. 用ASP.NET上传大文件

    作者:思归     微软MVP   http://blog.joycode.com/saucer/ 我们在上传大文件时都遇到过这样或那样的问题.设置很大的maxRequestLength值并不能完全解 ...

  7. php webuploader大文件,web uploader 上传大文件总结

    由于业务需要,需要上传大文件,已有的版本无法处理IE版本,经过调研,百度的 webuploader 支持 IE 浏览器,而且支持计算MD5值,进而可以实现秒传的功能. 大文件上传主要分为三部分,预上传 ...

  8. html5 上传超大文件,HTML5教程 如何拖拽上传大文件

    本篇教程探讨了HTML5教程 如何拖拽上传大文件,希望阅读本篇文章以后大家有所收获,帮助大家HTML5+CSS3从入门到精通 . < 前言: 大文件传输一直是技术上的一大难点.文件过大时,一些性 ...

  9. php上传图片k,PHP fastcgi模式上传大文件(大约有300多K)报错,

    PHP fastcgi模式上传大文件(大约有300多K)报错, 最近在项目中中上传图片时,大约有300多K,结果报了个服务器错误,以前从未遇到过,错误的内容如下: mod_fcgid: HTTP re ...

最新文章

  1. C#中有关数组和string引用类型或值类型的判断
  2. asp.net 取得上一页的url
  3. 泥浆配制_朝政泥浆——广西田阳县百东河水库溢洪道穿越钻泥浆配制简述(3)...
  4. udp如何知道对方关闭_聊聊tcp和udp那些事
  5. 一群猴子排成一圈,按1,2,...,n依次编号。然后从第1只开始数,数到第m只,把它踢出圈...
  6. gulp教程之gulp-imagemin压缩图片
  7. Sentinel 简介与API订阅发布
  8. chromium中的性能优化工具syzyProf
  9. KindEditor - 代码高亮
  10. 3万字操作系统常用知识总结
  11. 地形瓦片地图TiledMap AutoTiles自动图块
  12. Multisim入门
  13. 不删除磁盘内容,如何给C盘扩容
  14. ios 设置属性的center_iOS游戏平台Game Center成就显示设置指南
  15. android仿最新版本微信相册--附源码
  16. windowns下VS缺少头文件“unistd.h“的解决方案
  17. 使用Canal ClientAdapter实现Mysql的DDL、DML同步到PostgreSQL
  18. 【机器学习】李宏毅-预测PM2.5
  19. 英文caement水泥caement单词
  20. phpcms 添加顶踩功能

热门文章

  1. iOS小技能:解决TableVIew刷新数据带来的界面跳动问题
  2. 单反、微单、卡片相机的区别
  3. 来,开局先创建一个 app
  4. 基于Arduino Pro Mini的四轴飞行器
  5. 2FA的完整形式是什么?
  6. 三星 SCX-4216 中英对照表及三星传真机的清零方法
  7. 适合初学者练手的vue小商城项目(附github源码)
  8. Hello语音交友 v4.7.14
  9. amd服务器如何修改睿频,amd自动睿频怎么开_amd开启睿频教程
  10. 图像化界面开发之QT入门