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

📄 upfile.asp

📁 很漂亮的一个网络公司的源码
💻 ASP
字号:
<!--#include file="include/upload.asp"-->
<%
const upload_type=0   '上传方法:0=无惧无组件上传类,1=FSO上传 2=lyfupload,3=aspupload,4=chinaaspupload

Const MaxPerPage_Content=2000        '每页显示大约字符数
Const EnableUploadFile="Yes"        '是否开放文件上传
Const MaxFileSize=2000        '上传文件大小限制
Const SaveUpFilesPath="UpLoadImg"        '存放上传文件的目录
Const UpFileType="rar|gif|jpg|bmp|zip|png|swf|doc|exe|mid"        '允许的上传文件类型
Const DelUpFiles="Yes"        '删除文章时是否同时删除文章中的上传文件
dim upload,file,formName,SavePath,filename,fileExt
dim upNum
dim EnableUpload
dim Forumupload
dim ranNum
dim uploadfiletype
dim msg,founderr
msg=""
founderr=false
EnableUpload=false
SavePath = SaveUpFilesPath   '存放上传文件的目录
if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<%
if EnableUploadFile="No" then
	response.write "系统未开放文件上传功能"
else
	if session("IsAdmin")=""  then
		response.Write("请登录后再使用本功能!")
	else
		select case upload_type
			case 0
				call upload_0()  '使用化境无组件上传类
			case else
				'response.write "本系统未开放插件功能"
				'response.end
		end select
	end if
end if
%>
</body>
</html>
<%
Sub upload_0()    '使用化境无组件上传类
	Set upload=new xc_upload    '建立上传对象
	For each formName in upload.file '列出所有上传了的文件
		set file=upload.file(formName)  '生成一个文件对象
		if file.filesize<100 then
 			msg="请先选择你要上传的文件!"
			founderr=true
		end if
		if file.filesize>(MaxFileSize*1024) then
 			msg="文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!"
			founderr=true
		end if

		fileExt=lcase(file.FileExt)
		Forumupload=split(UpFileType,"|")
		for i=0 to ubound(Forumupload)
			if fileEXT=trim(Forumupload(i)) then
				EnableUpload=true
				exit for
			end if
		next
		if fileEXT<>"jpg" And fileEXT<>"gif" then
			EnableUpload=false
		end if
		if EnableUpload=false then
			msg="这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType
			founderr=true
		end if

		isimgurl=upload.form("isimgurl")

		strJS="<SCRIPT language=javascript>" & vbcrlf
		if founderr<>true then
			randomize
			ranNum=int(900*rnd)+100
			filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt

			file.SaveToFile Server.mappath(SavePath & FileName)   '保存文件

			msg="上传文件成功!"
			
			strJS=strJS & "parent.form.ADSrc.value='" & FileName & "';" & vbcrlf
		End if
		strJS=strJS & "alert('" & msg & "');" & vbcrlf
	  	strJS=strJS & "history.go(-1);" & vbcrlf		
		strJS=strJS & "location.href='upload.asp'"
	  	strJS=strJS & "</script>"
	  	response.write strJS
		set file=nothing
	next
	set upload=nothing
end sub
%>

⌨️ 快捷键说明

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