⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savetofile.asp

📁 在ASP中调用的无组件上传
💻 ASP
字号:
<%OPTION EXPLICIT%>
<!--#include FILE="clsUp.asp"-->
<%
dim upfile,formPath,ServerPath,FSPath,formName,FileName,oFile,upfilecount
upfilecount=0
set upfile=new clsUp ''建立上传对象
upfile.NoAllowExt="asp;exe;htm;html;aspx;cs;vb;js;"	'设置上传类型的黑名单
upfile.GetData (10240000)   '取得上传数据,限制最大上传10M
%>
<html>
<head>
<title>文件上传</title>
<style type="text/css">
<!--
.p9{ font-size: 9pt; font-family: 宋体 }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="20" topmargin="20" class="p9">
<p class="tx1"><font color="#0000FF" size="4"><%=upfile.Version%> </font></p>
<hr size=1 noshadow width=300 align=left><%
if upfile.isErr then  '如果出错
    select case upfile.isErr
	case 1
	Response.Write "你没有上传数据呀???是不是搞错了??"
	case 2
	Response.Write "你上传的文件超出我们的限制,最大10M"
	end select
	else
%>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" class="p9" style="border-collapse: collapse">
  <tr bgcolor="#CCCCCC"> 
    <td height="25" valign='middle'> 本地文件 </td>
    <td  valign='middle'> 大小(字节) </td>
    <td  valign='middle'> 上传到 </td>
    <td  valign='middle'> 状态 </td>
  </tr>  
<%
	FSPath=GetFilePath(Server.mappath("upfile.asp"),"\")'取得当前文件在服务器路径
	ServerPath=GetFilePath(Request.ServerVariables("HTTP_REFERER"),"/")'取得在网站上的位置
	for each formName in upfile.file '列出所有上传了的文件
	   set oFile=upfile.file(formname)
	   FileName=upfile.form(formName)'取得文本域的值
	   if not FileName>"" then  FileName=oFile.filename'如果没有输入新的文件名,就用原来的文件名
	   upfile.SaveToFile formname,FSPath&FileName   ''保存文件 也可以使用AutoSave来保存,参数一样,但是会自动建立新的文件名
	 %>
<tr> 
    <td height="20"  valign='middle'> <%=oFile.FilePath&oFile.FileName%> </td>
    <td  valign='middle'> <%=oFile.filesize%> </td>
    <td  valign='middle'> <A HREF="<%=serverpath&FileName%>"><%=FileName%></A> </td>
    <td  valign='middle'> <%
    if upfile.iserr then 
		Response.Write upfile.errmessage
		else
		upfilecount=upfilecount+1
		Response.Write "上传成功"
		end if
		%> </td>
  </tr><%
	 set oFile=nothing
	next
%>
  <tr> 
    <td colspan="3" height="25" valign='middle'> 一共上传了<%=upfileCount%>个文件</td>
  </tr>
<%
end if
set upfile=nothing  '删除此对象
%>
</table>
<p></p>

</p>[<a href="upfiletofile.htm">返回</a>]
  <table align="center" class="p9">
    <tr>
      <td height="50" align="middle">版权没有 盗版不究  技术支持 <A HREF="http://bbs.lkstar.com" target="_blank">http://bbs.lkstar.com </A> </td>
    </tr>
    </table>

</body>
</html>

<%
function GetFilePath(FullPath,str)
  If FullPath <> "" Then
    GetFilePath = left(FullPath,InStrRev(FullPath, str))
    Else
    GetFilePath = ""
  End If
End function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -