您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

ASP文件上传工具(只能上传一定大小文件)

来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:34 点击:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
  Response.Buffer = True
  Server.ScriptTimeOut=9999999
  On Error Resume Next
%>
<head>  www.2cto.com
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta name="description" content="ASP文件上传工具" />
<style type="text/css">
<!--
body,input {font-size:12px;}
-->
</style>
<title>ASP文件上传工具</title>
</head>
<body id="body">
<%
  upurl=Request.ServerVariables("URL")
  ExtName = "jpg,gif,png,txt,rar,zip,doc,pdf"    '允许扩展名
  SavePath = "upload"                    '保存路径
  If Right(SavePath,1)<>"/" Then SavePath=SavePath&"/" '在目录后加(/)
  CheckAndCreateFolder(SavePath)
  UpLoadAll_a = Request.TotalBytes '取得客户端全部内容
  If(UpLoadAll_a>0) Then
    Set UploadStream_c = Server.CreateObject("ADODB.Stream")
    UploadStream_c.Type = 1
    UploadStream_c.Open
    UploadStream_c.Write Request.BinaryRead(UpLoadAll_a)
    UploadStream_c.Position = 0
    FormDataAll_d = UploadStream_c.Read
    CrLf_e = chrB(13)&chrB(10)
    FormStart_f = InStrB(FormDataAll_d,CrLf_e)
    FormEnd_g = InStrB(FormStart_f+1,FormDataAll_d,CrLf_e)
    Set FormStream_h = Server.Createobject("ADODB.Stream")
    FormStream_h.Type = 1
    FormStream_h.Open
    UploadStream_c.Position = FormStart_f + 1
    UploadStream_c.CopyTo FormStream_h,FormEnd_g-FormStart_f-3
    FormStream_h.Position = 0
    FormStream_h.Type = 2
    FormStream_h.CharSet = "GB2312"
    FormStreamText_i = FormStream_h.Readtext
    FormStream_h.Close
    FileName_j = Mid(FormStreamText_i,InstrRev(FormStreamText_i,"\")+1,FormEnd_g)
    If(CheckFileExt(FileName_j,ExtName)) Then
      SaveFile = Server.MapPath(SavePath & FileName_j)
      If Err Then
        Response.Write "文件上传: <span style=""color:red;"">文件上传出错!</span> <a href=""" & upurl&""">重新上传文件</a><br />"
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • WAP常见问题问答大全(四)
  • ASP开发必备:WEB打印代码大全
  • ASP调用系统ping命令
  • asp缓存技术
  • ASP教程:第三篇 ASP基础
  • 用ASP+XML打造留言本(4)
  • 关于ASP Recordset 分页出现负数解决方法及建议
  • 用asp怎样编写文档搜索页面(5)
  • ASP处理多关键词查询实例代码
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1