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

📄 upfile_pic.asp

📁 嘉缘人才6.0精简 ,很好用的人才系统
💻 ASP
字号:
<!--#include file="../../conn/conn.asp" -->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../checkvalid.asp" -->
<%
OldUrl=LCase(Request.ServerVariables("HTTP_REFERER"))

If InStr(OldUrl,"/admin/ad/upload_pic.asp")<>0 then
Else
	Response.Write "<script>alert('对不起请勿外部提交');history.back();</script>"	
	Response.End()
End if
%>
<!--#include file="upfile_class.asp"-->
<%
const SaveUpFilesPath="ads"

const UpFileType_pic="jpg|gif|bmp|png"
const UpFileType_flash="swf"

const MaxFileSize=100

dim upload,oFile,formName,SavePath,filename,fileExt,oFileSize
dim EnableUpload
dim UpFileType,arrUpFileType
dim ranNum
dim msg,FoundErr

msg=""
FoundErr=false
EnableUpload=false

SavePath ="../../"&SaveUpFilesPath   '存放上传文件的目录
if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/)
%>
<html>
<head>
<title>上传文件</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>
<body style="font-size:12px; margin-top:5px;">
<%

call upload_0()  '使用化境无组件上传类

%>
</body>
</html>
<%
sub upload_0()    '使用化境无组件上传类
	set upload=new upfile_class ''建立上传对象
	upload.GetData(104857600)   '取得上传数据,限制最大上传100M
	if upload.err > 0 then  '如果出错
		select case upload.err
			case 1
				response.write "请先选择你要上传的文件!"
			case 2
				response.write "你上传的文件总大小超出了最大限制(100M)"
		end select
		response.end
	end if

	for each formName in upload.file '列出所有上传了的文件
		set ofile=upload.file(formName)  '生成一个文件对象
		oFileSize=ofile.filesize
		if oFileSize<100 then
			msg="请先选择你要上传的文件!"
			FoundErr=True
			
		elseif ofilesize>(MaxFileSize*1024) then
 			msg="文件大小超过了限制,最大只能上传"& CStr(MaxFileSize) & "K的文件!"
			FoundErr=true
		end if
		UpFileType="jpg,gif,bmp,png,swf"
		fileExt=lcase(ofile.FileExt)
		arrUpFileType=split(UpFileType,",")
		for i=0 to ubound(arrUpFileType)
			if fileEXT=trim(arrUpFileType(i)) then
				EnableUpload=true
				exit for
			end if
		next
		if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" then
			EnableUpload=false
		end if
		if EnableUpload=false then
			msg="这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType
			FoundErr=true
		end if
		
		
		strJS="<SCRIPT language=javascript>" & vbcrlf
		if FoundErr<>true then
			randomize
			ranNum=int(900*rnd)+100
			FName=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
			filename=SavePath&FName
			ofile.SaveToFile Server.mappath(FileName)   '保存文件
			Response.Write "文件上传成功!"
			gif_url="/"&SaveUpFilesPath&"/"&FName
			strJS=strJS & "parent.document.addadschk.gif_url.value='" & siteurl & gif_url & "';" & vbcrlf
			
		else
			strJS=strJS & "alert('" & msg & "');" & vbcrlf
			strJS=strJS & "window.location='Upload_pic.asp';" & vbcrlf
		end if
		strJS=strJS & "</script>" & vbcrlf
		response.write strJS
		
		set file=nothing
	next
	set upload=nothing
end sub
%>


⌨️ 快捷键说明

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