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

📄 upfile.asp

📁 文件上传系统 无组件上传 可选择文件类型 上传文件的大小
💻 ASP
字号:
<!--#include file=conn.asp-->
<%
set rsmap = Server.CreateObject("ADODB.Recordset")
   mapsql = "SELECT * FROM setmap"
rsmap.Open mapsql,conn

FilePath=rsmap("filepath")
FileMaxSize=rsmap("size")
FileType=rsmap("leixin")
fileweb=rsmap("weburl")
nameset =rsmap("nameset")
pathset =rsmap("pathset")
%>
<% 
''将当前的日期和时间转为文件名
function makefilename(fname)
  fname = now()
  fname = replace(fname,"-","")
  fname = replace(fname," ","") 
  fname = replace(fname,":","")
  fname = replace(fname,"PM","")
  fname = replace(fname,"AM","")
  fname = replace(fname,"上午","")
  fname = replace(fname,"下午","")
  makefilename=fname
end function 
%>
<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>WLONG3D文件上传系统 | http://www.wlong3d.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css"> 
<!-- 
td {  font-size: 9pt} 
a {  color: #000000; text-decoration: none} 
a:hover {  text-decoration: underline} 
.tx {  height: 16px; width: 30px; border-color: black black #000000; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 9pt; background-color: #eeeeee; color: #0000FF} 
.bt {  font-size: 9pt; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; height: 16px; width: 80px; background-color: #eeeeee; cursor: hand} 
.tx1 { height: 20px; width: 30px; font-size: 9pt; border: 1px solid; border-color: black black #000000; color: #0000FF} 
--> 
</style>
</head>
<body>
<div align="center"><br>
  <br>
</div>
<table width="64%" border="1" align="center" cellpadding="2" cellspacing="1" bordercolor="#000000">
  <tr>
    <td bgcolor="#CCCCCC"> 
      <div align="center"></div>
    </td>
  </tr>
  <tr>
    <td>
      <div align="center"><br>
        <%
dim upload,file,formName,iCount
set upload=new upload_5xSoft ''建立上传对象

if Pathset > 0 then   ''得到上传目录
 UpFilePath = upload.form("filepath")
else
 UpFilePath = FilePath
 ''在目录后加(/)
 if right(UpFilePath,1)<>"/" then UpFilePath=UpFilePath&"/" 
end if

iCount=0
for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
 if file.FileSize<FileMaxSize then ''如果未超过文件大小限制

 if FileType<>"" then	'如果限制了上传文件类型
 if Instr(FileType,GetExtendName(file.FileName)) then
	TypeFlag = 1        '文件为允许的类型
 else
	TypeFlag = 0		'文件为不允许的类型
 	Response.write "不支持您所上传的文件类型:"
	Response.write GetExtendName(file.FileName)
	Response.write "<br>"
end if
 else
 TypeFlag = 1			'没有限制上传文件类型
 
 end if

  if TypeFlag = 1 then 
  vfname = makefilename(now())
     if nameset = 1 then
  fname = vfname & iCount & "." & GetExtendName(file.FileName)
       elseif nameset =2 then
	   fname = file.FileName
	     elseif nameset = 3 then
		 fname = vfname & iCount & file.FileName
		 end if
  file.SaveAs Server.mappath(UpFilePath&fname)   ''保存文件
  response.write file.FilePath&file.FileName&" ("&file.FileSize&") => 上传文件成功! <br>"
  response.write "你的文件路径是("&fileweb&UpFilePath&fname&")<br>"
  response.write "请将文件路径拷贝到相应的栏目中!<br>"
  iCount=iCount+1
' fileStr = fileStr & "<img src='pic/addon.gif'><a href='"& UpFilePath&file.FileName&"' target='_blank'>查看上传的文件:<font color='red'>" & file.FileName &"</font> ("& file.FileSize &" kb)</a><br>"
 FileNameStr = UpFilePath&fname


end if

 else
 response.write "文件大小超出限制,您最多可以上传 "& FileMaxSize &"个字节的文件数据"
 exit for
 end if
 end if
 set file=nothing
next
set upload=nothing  ''删除此对象

if iCount>0 then
	response.write "<br>成功地上传了"&iCount&" 个文件!"
 response.write "<br>"&Msg&"<br><br><br><center> [<a href=""javascript:history.back();""><<返回</a>]  [<a href=""javascript:window.close();"">关闭窗口</a>]</center>"
' response.end
else
	response.write "<br>上传文件失败,请向管理员反应!"
 response.write "<br>"&Msg&"<br><br><br><center> [<a href=""javascript:history.back();""><<返回</a>]  [<a href=""javascript:window.close();"">关闭窗口</a>]</center>"
' response.end
end if

sub HtmEnd(Msg)
 set upload=nothing
end sub


function GetExtendName(FileName)
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>
      </div>
    </td>
  </tr>
  <tr>
    <td bgcolor="#eeeeee">
      <div align="center"></div>
    </td>
  </tr>
</table>
</body>
</html>

<%
rsmap.Close
set rsmap=nothing
conn.close
set conn=nothing
%>

⌨️ 快捷键说明

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