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

📄 upload_save6.asp

📁 后台路径:admin/login.asp 用户名:manage 密码:fansyou
💻 ASP
字号:
 
<% 
''将当前的日期和时间转为文件名
function makefilename(fname)
  cctime=now()
  fname =year(cctime)& month(cctime)& day(cctime)&hour(cctime)&minute(cctime)&second(cctime) 
  makefilename=fname
end function 
%>
<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>文件上传系统 </title>
</head>
<body>
 <%
dim upload,file,formName,iCount,filemaxsize
filemaxSize=204800 'MaxSize is :200KB
fileType=".gif,.jpg"
set upload=new upload_5xSoft ''建立上传对象

 UpFilePath ="upload_img/"   ''得到上传目录 ''在目录后加(/)
iCount=0
for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 ''如果 FileSize > 0 说明有文件数据
 if file.filesize>204800 then 
  response.write " <font color=red>出现以下错误:</font><br><li>文件尺寸过大,请重新选择文件!</li><br><br><div align=center><a href='javascript:history.go(-1)'>返回重新选择</a></div>"
  response.end
end if
 if file.FileSize>0 and file.FileSize<FileMaxSize then ''如果未超过文件大小限制
 ttype=GetExtendName(file.FileName)
 		if Instr(FileType,ttype)>0 then
			TypeFlag = 1        '文件为允许的类型
			fname= makefilename(now())
  FileNameStr = UpFilePath&fname&"."&ttype 
  file.SaveAs Server.mappath(FileNameStr)   ''保存文件
  response.write "上传文件"&FileNameStr&"成功! <br>"

		 else
			TypeFlag = 0		'文件为不允许的类型
 			Response.write "不支持您所上传的文件类型:"
			Response.write GetExtendName(file.FileName)
			Response.write "<br>"
		end if
 
 else
 response.write "文件大小超出限制,您最多可以上传 "& FileMaxSize &"个字节的文件数据"
 exit for
 end if

 set file=nothing
next
set upload=nothing  ''删除此对象

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>
</table>

<script language="JavaScript">
 
window.opener.form1.picurl6.value="<%=FileNameStr%>"
window.close()
</script>
</body>
</html>

⌨️ 快捷键说明

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