<!--#include file="NC_UploadCls.Asp" -->
<%
Class UpLoadFile
	Private ErrMsg
	Private SucMsg
	Private Founderr
	Private NC_Admin
	Private sType
	Private UpFileType
	Private UpFileSize
	Private sAction
	Private Action
	Private UpFilePath
	Private UploadFinish
	Private Upload_type
	Private i
	Private upset
	Private UpFileUrl
	Private UpNum

	Private Sub Class_Initialize()
		On Error Resume Next
		Founderr = False
		Set NC_Admin = New Check
	End Sub

	Private Sub Class_Terminate()
		If IsObject(NC_Admin) Then
			Set NC_Admin = Nothing
		End If
	End Sub

	Public Sub Init_UpLoad()
		Server.ScriptTimeOut = 99999
		NC_Admin.Check
		sAction = UCase(Trim(Request.QueryString("action")))
		sType = UCase(Trim(Request.QueryString("type")))
		'*****************************************************************************
		'设置上传方式upload_type值： 0＝无组件，1＝lyfupload 1.2版
		'*****************************************************************************
		Upload_type = CInt(DownsysClass.Setting(28)) '默认设置上传组件
		'*****************************************************************************
		UploadFinish = False
		Select Case sType
			Case "IMAGE"
				UpFileType = DownsysClass.Setting(27) '上传图片类型
				UpFileSize = CStr(DownsysClass.Setting(22)) * 1024 '上传文件大小
				UpFilePath = DownsysClass.SetupDir & DownsysClass.Setting(26) '上传图片路径
			Case "FLASH"
				UpFileType = "swf" '上传类型
				UpFileSize = CStr(DownsysClass.Setting(23)) * 1024 '上传文件大小
				UpFilePath = DownsysClass.SetupDir & DownsysClass.Setting(26) '上传文件路径
			Case Else
				UpFileType = DownsysClass.Setting(25) '上传文件类型
				UpFileSize = CStr(DownsysClass.Setting(23)) * 1024 '上传文件大小
				UpFilePath = DownsysClass.SetupDir & DownsysClass.Setting(24) '上传文件路径
		End Select
		Call ShowForm ' 显示上传表单
		If sAction = "SAVE" Then
			If NC_Admin.ChkAdmin("66", NC_Admin.Purview) = False Then
				Response.Write ("<script>alert('对不起!您没有上传文件的权限。');history.go(-1)</script>")
				Exit Sub
			End If
			Select Case Upload_type
				Case 0
					Call Upload_0
				Case 1
					Call Upload_1
				Case 999
					Response.Write ("<script>alert('本系统未开放上传功能!');history.go(-1)</script>")
					Exit Sub
				Case Else
					Response.Write ("<script>alert('本系统未开放上传功能!');history.go(-1)</script>")
					Exit Sub
					Response.End
			End Select
		End If
	End Sub

	Private Sub ShowForm()
		Response.Write "<HTML>" & Chr(13) & Chr(10)
		Response.Write "<HEAD>" & Chr(13) & Chr(10)
		Response.Write "<TITLE>文件上传</TITLE>" & Chr(13) & Chr(10)
		Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">" & Chr(13) & Chr(10)
		Response.Write "<Link rel=""stylesheet"" type=""text/css"" href=""pop.css"">" & Chr(13) & Chr(10)
		Response.Write "<style type=""text/css"">" & Chr(13) & Chr(10)
		Response.Write "body, a, table, div, span, td, th, input, select{font:9pt;font-family: ""宋体"", Verdana, Arial, Helvetica, sans-serif;}" & Chr(13) & Chr(10)
		Response.Write "body {padding:0px;margin:0px}" & Chr(13) & Chr(10)
		Response.Write "</style>" & Chr(13) & Chr(10)
		Response.Write "<script language=""JavaScript"" src=""Editor/dialog.js""></script>" & Chr(13) & Chr(10)
		Response.Write "</head>" & Chr(13) & Chr(10)
		Response.Write "<body bgcolor=menu>" & Chr(13) & Chr(10)
		Response.Write "<form action=""?action=save&type="
		Response.Write sType
		Response.Write """ method=post name=myform enctype=""multipart/form-data"">" & Chr(13) & Chr(10)
		Response.Write "<input type=file name=uploadfile size=1 style=""width:100%"">" & Chr(13) & Chr(10)
		Response.Write "可上传的文件：" & UpFileType & "<br>单个文件大小：" & CStr(UpFileSize) / 1024 & " KB"
		Response.Write "</form>" & Chr(13) & Chr(10)
		Response.Write "<script language=javascript>" & Chr(13) & Chr(10)
		Response.Write "var sAllowExt = """
		Response.Write UpFileType
		Response.Write """;" & Chr(13) & Chr(10)
		Response.Write "// 检测上传表单" & Chr(13) & Chr(10)
		Response.Write "function CheckUploadForm() {" & Chr(13) & Chr(10)
		Response.Write Chr(9) & "if (!IsExt(document.myform.uploadfile.value,sAllowExt)){" & Chr(13) & Chr(10)
		Response.Write Chr(9) & Chr(9) & "parent.UploadError(""提示：\n\n请选择一个有效的文件，\n支持的格式有（""+sAllowExt+""）！"");" & Chr(13) & Chr(10)
		Response.Write Chr(9) & Chr(9) & "return false;" & Chr(13) & Chr(10)
		Response.Write Chr(9) & "}" & Chr(13) & Chr(10)
		Response.Write Chr(9) & "return true" & Chr(13) & Chr(10)
		Response.Write "}" & Chr(13) & Chr(10)
		Response.Write "// 提交事件加入检测表单" & Chr(13) & Chr(10)
		Response.Write "var oForm = document.myform ;" & Chr(13) & Chr(10)
		Response.Write "oForm.attachEvent(""onsubmit"", CheckUploadForm) ;" & Chr(13) & Chr(10)
		Response.Write "if (! oForm.submitUpload) oForm.submitUpload = new Array() ;" & Chr(13) & Chr(10)
		Response.Write "oForm.submitUpload[oForm.submitUpload.length] = CheckUploadForm ;" & Chr(13) & Chr(10)
		Response.Write "if (! oForm.originalSubmit) {" & Chr(13) & Chr(10)
		Response.Write Chr(9) & "oForm.originalSubmit = oForm.submit ;" & Chr(13) & Chr(10)
		Response.Write Chr(9) & "oForm.submit = function() {" & Chr(13) & Chr(10)
		Response.Write Chr(9) & Chr(9) & "if (this.submitUpload) {" & Chr(13) & Chr(10)
		Response.Write Chr(9) & Chr(9) & Chr(9) & "for (var i = 0 ; i < this.submitUpload.length ; i++) {" & Chr(13) & Chr(10)
		Response.Write Chr(9) & Chr(9) & Chr(9) & Chr(9) & "this.submitUpload[i]() ;" & Chr(13) & Chr(10)
		Response.Write Chr(9) & Chr(9) & Chr(9) & "}" & Chr(13) & Chr(10)
		Response.Write Chr(9) & Chr(9) & "}" & Chr(13) & Chr(10)
		Response.Write Chr(9) & Chr(9) & "this.originalSubmit() ;" & Chr(13) & Chr(10)
		Response.Write Chr(9) & "}" & Chr(13) & Chr(10)
		Response.Write "}" & Chr(13) & Chr(10)
		Response.Write "// 上传表单已装入完成" & Chr(13) & Chr(10)
		Response.Write "try {" & Chr(13) & Chr(10)
		Response.Write Chr(9) & "parent.UploadLoaded();" & Chr(13) & Chr(10)
		Response.Write "}" & Chr(13) & Chr(10)
		Response.Write "catch(e){" & Chr(13) & Chr(10)
		Response.Write "}" & Chr(13) & Chr(10)
		Response.Write "</script>" & Chr(13) & Chr(10)
		Response.Write "</body>" & Chr(13) & Chr(10)
		Response.Write "</html>" & Chr(13) & Chr(10)
	End Sub
	'*************************************************************
	'过程作用：无组件上传类
	'*************************************************************
	Private Sub Upload_0()
		Dim objUpload
		Dim uploadpath
		Dim FormName
		Set objUpload = New Upload_Cls '建立上传对象
		objUpload.FileType = UpFileType '上传文件类型
		uploadpath = objUpload.CreatePath(UpFilePath) '按日期生成目录
		objUpload.SavePath = UpFilePath & uploadpath '保存上传文件
		objUpload.FileSize = CStr(UpFileSize) '上传文件大小
		objUpload.UploadOpen '打开上传对象
		FormName = objUpload.Form("uploadfile")
		Select Case objUpload.Form("uploadfile_Err")
	Case -1:
			Response.Write ("<script>alert('您没有选择要上传的文件名，文件上传失败!');history.go(-1)</script>")
			Exit Sub
	Case 0:
			Call OutScript("parent.UploadSaved('" & UpFilePath & uploadpath & FormName & "')")
	Case 1:
			Response.Write ("<script>alert('文件尺寸过大!\n允许上传的文件大小：" & CStr(UpFileSize) / 1024 & " KB');history.go(-1)</script>")
			Exit Sub
	Case 2:
			Response.Write ("<script>alert('上传的文件类型不对!\n可以上传的文件类型如下\n" & UpFileType & "');history.go(-1)</script>")
			Exit Sub
	Case 3:
			Response.Write ("<script>alert('文件太大且格式不对，拒绝上传!\n可以上传的文件类型如下\n" & UpFileType & "\n允许上传的文件大小：" & CStr(DownsysClass.Setting(23)) & " KB');history.go(-1)</script>")
			Exit Sub
		End Select
		Set objUpload = Nothing
	End Sub
	'*************************************************************
	'过程作用：Lyfupload组件上传
	'*************************************************************
	Private Sub Upload_1()
		Dim objLyf
		Dim ss
		Dim FileExt
		Dim filename
		Dim formPath
		Dim File_name
		Dim patharray
		Dim FileName_path
		Dim File_Ext
		Dim FormName
		Set objLyf = Server.CreateObject("LyfUpload.UploadFile")
		objLyf.maxsize = CStr(UpFileSize) '上传文件大小
		objLyf.extname = UpFileType '上传文件类型
		If objLyf.Request("uploadfile") = "" Or IsNull(objLyf.Request("uploadfile")) Then
			Response.Write "<script>alert('请没有选择要上传的文件!');history.go(-1)</script>"
			Exit Sub
		End If
		formPath = CreatePath(UpFilePath)
		FormName = objLyf.Request("uploadfile")
		patharray = Split(FormName, """")
		If Len(patharray(1)) <> 0 Then
			FileName_path = Split(patharray(1), ".")
			'File_Ext = Split(FileName_path(UBound(FileName_path)), ".")
			FileExt = FileName_path(1)
		End If
		File_name = CreateName
		filename = File_name & "." & FileExt
		ss = objLyf.SaveFile("uploadfile", Server.MapPath(UpFilePath & formPath), True, filename)
		If ss = "3" Then
			Response.Write ("<script>alert('文件名重复!');history.go(-1)</script>")
			Exit Sub
		ElseIf ss = "0" Then
			Response.Write ("<script>alert('文件尺寸过大!\n允许上传的文件大小：" & CStr(UpFileSize) / 1024 & " KB');history.go(-1)</script>")
			Exit Sub
		ElseIf ss = "1" Then
			Response.Write ("<script>alert('上传的文件类型不对!\n可以上传的文件类型如下\n" & UpFileType & "');history.go(-1)</script>")
			Exit Sub
		ElseIf ss = "" Then
			Response.Write ("<script>alert('您没有选择要上传的文件名，文件上传失败!');history.go(-1)</script>")
			Exit Sub
		Else
			Call OutScript("parent.UploadSaved('" & UpFilePath & formPath & filename & "')")
		End If
		Set objLyf = Nothing
	End Sub

	Public Sub Init_UpFile()
		Server.ScriptTimeOut = 99999
		NC_Admin.Check
		Action = UCase(Trim(Request.QueryString("action")))
		sType = UCase(Trim(Request.QueryString("type")))
		UpNum = CInt(Request.QueryString("UpNum"))
		upset = CInt(DownsysClass.Setting(29))
		'*****************************************************************
		'设置上传方式upload_type值： 0＝无组件，1＝lyfupload 1.2版
		'*****************************************************************
		Upload_type = CInt(DownsysClass.Setting(28)) '默认设置上传组件
		Select Case sType
			Case "IMAGE"
				UpFileType = DownsysClass.Setting(27) '上传图片类型
				UpFileSize = CStr(DownsysClass.Setting(22)) * 1024 '上传文件大小
				UpFilePath = DownsysClass.SetupDir & DownsysClass.Setting(26) '上传图片路径
			Case "FILE"
				UpFileType = DownsysClass.Setting(25) '上传类型
				UpFileSize = CStr(DownsysClass.Setting(23)) * 1024 '上传文件大小
				UpFilePath = DownsysClass.SetupDir & DownsysClass.Setting(24) '上传文件路径
			Case Else
				UpFileType = DownsysClass.Setting(25) '上传文件类型
				UpFileSize = CStr(DownsysClass.Setting(23)) * 1024 '上传文件大小
				UpFilePath = DownsysClass.SetupDir & DownsysClass.Setting(24) '上传文件路径
		End Select
		Response.Write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"">"
		Response.Write "<html>" & vbCrLf
		Response.Write "<head>" & vbCrLf
		Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">" & vbCrLf
		Response.Write "<title>文件上传</title>" & vbCrLf
		Response.Write "<LINK href=""style.css"" type=text/css rel=stylesheet>" & vbCrLf
		Response.Write "<META content=""MSHTML 6.00.2600.0"" name=GENERATOR></head>" & vbCrLf
		Response.Write "<script language=JavaScript>" & vbCrLf
		Response.Write "<!--//" & vbCrLf
		Response.Write "function uploadframe()" & vbCrLf
		Response.Write "{" & vbCrLf
		Response.Write " document.getElementById(""Setupload"").style.display="""";" & vbCrLf
		Response.Write " document.getElementById(""allupload"").style.display=""none"";" & vbCrLf
		Response.Write " document.getElementById(""allupfile"").style.display=""none"";" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "function setid(upcount)" & vbCrLf
		Response.Write "{" & vbCrLf
		Response.Write " str='';" & vbCrLf
		Response.Write " for(i=1;i<=window.form1.upcount.value;i++)" & vbCrLf
		Response.Write " str+='文件'+i+':<input type=""file"" name=""upfile'+i+'"" style=""width:90%""><br>';" & vbCrLf
		Response.Write " window.upid.innerHTML=str;" & vbCrLf
		Response.Write "	var num=i*18" & vbCrLf
		If sType = "IMAGE" Then
			Response.Write "	var obj=parent.document.getElementById(""image"");" & vbCrLf
			Response.Write "	if (parseInt(obj.height)+num>=42) {" & vbCrLf
			Response.Write "		obj.height = 42 + num;  " & vbCrLf
			Response.Write "	}" & vbCrLf
		Else
			Response.Write "	var obj=parent.document.getElementById(""ad"");" & vbCrLf
			Response.Write "	if (parseInt(obj.height)+num>=42) {" & vbCrLf
			Response.Write "		obj.height = 42 + num;  " & vbCrLf
			Response.Write "	}" & vbCrLf
		End If
		Response.Write "}" & vbCrLf
		Response.Write "//-->" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<body leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>" & vbCrLf
		Response.Write "<div align=center>"
		Response.Write "<table style=""width:100%;height:100%"" border=""0"" cellspacing=""0"" cellpadding=""3"" align=center>"
		Response.Write "<tr vAlign=top>"
		Response.Write "<td class=forumRow>"
		If Action = "SAVE" Then
			If NC_Admin.ChkAdmin("66", NC_Admin.Purview) = False Then
				Response.Write ("<script>alert('对不起!您没有上传文件的权限。');history.go(-1)</script>")
				Exit Sub
			End If
			Select Case Upload_type
				Case 0
					Call UpFile_0
				Case 1
					Call UpFile_1
				Case 999
					Response.Write ("<script>alert('本系统未开放上传功能!');history.go(-1)</script>")
					Exit Sub
				Case Else
					Response.Write ("<script>alert('本系统未开放上传功能!');history.go(-1)</script>")
					Exit Sub
					Response.End
			End Select
		Else
			Response.Write "<table style=""width:100%;height:100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=center>"
			Response.Write "<form action='?action=save&type=" & sType & "&upnum=" & UpNum & "' method=post name=form1 enctype=""multipart/form-data"">"
			Response.Write "<tr vAlign=top>"
			Response.Write "<TD noWrap valign=top>" & vbCrLf
			Response.Write "<DIV id=allupfile>" & vbCrLf
			Response.Write "<b>文件上传</b>： "
			Response.Write "</Div>" & vbCrLf
			Response.Write "<DIV id=Setupload style=""display:none"">" & vbCrLf
			Response.Write "选择上传数量:" & vbCrLf
			Response.Write "<select name=""upcount"" onChange=""setid(this.value)"">" & vbCrLf
			For i = 1 To CInt(DownsysClass.Setting(30))
				Response.Write " <option value='" & i & "'"
				If i = 1 Then Response.Write " selected"
				Response.Write ">" & i & "</option>" & vbCrLf
			Next
			Response.Write "</Div>" & vbCrLf
			Response.Write "</TD>" & vbCrLf
			Response.Write "<TD id=""upid"" align=center width='80%' noWrap valign=top>" & vbCrLf
			Response.Write "<input type=""file"" name=""upfile1"" style=""width:96%""></TD>" & vbCrLf
			Response.Write "<td width='8%' valign=top>" & vbCrLf
			Response.Write "<input type=""submit"" name=""Submit"" value=""上传文件"">" & vbCrLf
			Response.Write "</td>" & vbCrLf
			If CInt(upset) = 1 Then
				Response.Write "<td id=allupload valign=top width='8%'>" & vbCrLf
				Response.Write "<input type=""button"" name=""setload"" onClick=""uploadframe();"" value=""批量上传"">" & vbCrLf
				Response.Write "</td>" & vbCrLf
			End If
			Response.Write "</tr>"
			Response.Write "<tr vAlign=top>"
			Response.Write "<TD colspan=4 class=forumRow valign=top>" & vbCrLf
			Response.Write "允许上传的文件类型：" & UpFileType & " 　大小：" & GetFileSize(UpFileSize) & ""
			Response.Write "</td>"
			Response.Write "</tr></form>"
			Response.Write "</table>"
		End If
		Response.Write "</td>"
		Response.Write "</tr>"
		Response.Write "</table>"
		Response.Write "</div></body>" & vbCrLf
		Response.Write "</html>"
	End Sub
	'*************************************************************
	'过程作用：无组件上传类
	'*************************************************************
	Private Sub UpFile_0()
		Dim objUpload
		Dim uploadpath
		Dim FormName
		Dim filename
		Set objUpload = New Upload_Cls '建立上传对象
		objUpload.FileType = UpFileType '上传文件类型
		uploadpath = objUpload.CreatePath(UpFilePath) '按日期生成目录
		objUpload.SavePath = UpFilePath & uploadpath '保存上传文件
		objUpload.FileSize = CStr(UpFileSize) '上传文件大小
		objUpload.UploadOpen '打开上传对象
		For i = 1 To UBound(objUpload.FileItem)
			If i > 1 And CInt(DownsysClass.Setting(29)) = 0 Then
				Response.Write ("<script>alert('本系统没有开启批量上传功能!');history.go(-1)</script>")
				Exit Sub
			End If
			If i > CInt(DownsysClass.Setting(30)) Then
				Response.Write ("<script>alert('批量上传超过了限制!\n每次最多只能上传文件 " & CInt(DownsysClass.Setting(30)) & " 个');history.go(-1)</script>")
				Exit Sub
			End If
			FormName = objUpload.FileArray(CInt(i))
			filename = objUpload.Form(FormName)
			Select Case objUpload.Form(FormName & "_Err")
	Case -1:
				Response.Write ("<script>alert('您没有选择要上传的文件名，文件上传失败!');history.go(-1)</script>")
				Exit Sub
	Case 0:
				UpFileUrl = UpFilePath & uploadpath & filename
				If i <= UpNum Then
					Call OutputScript(UpFileUrl, i)
				Else
					Response.Write ("<input type=""text"" name=""file1"" style=""width:100%"" value='" & UpFileUrl & "'> ")
					Response.Write ("文件上传成功! 文件大小: " & GetFileSize(objUpload.Form(FormName & "_Size")) & "&nbsp;&nbsp;[ <a href=# onclick=history.go(-1)>继续上传</a> ]")
				End If
	Case 1:
				Response.Write ("<script>alert('文件尺寸过大!\n允许上传的文件大小：" & CStr(UpFileSize) / 1024 & " KB');history.go(-1)</script>")
				Exit Sub
	Case 2:
				Response.Write ("<script>alert('上传的文件类型不对!\n可以上传的文件类型如下\n" & UpFileType & "');history.go(-1)</script>")
				Exit Sub
	Case 3:
				Response.Write ("<script>alert('文件太大且格式不对，拒绝上传!\n可以上传的文件类型如下\n" & UpFileType & "\n允许上传的文件大小：" & CStr(DownsysClass.Setting(23)) & " KB');history.go(-1)</script>")
				Exit Sub
			End Select
		Next
		If CInt(objUpload.Form("upcount")) <= UpNum Then
			Response.Write "<script language=javascript>alert('文件上传成功!');history.go(-1);</script>" & vbCrLf
		End If
		Set objUpload = Nothing
	End Sub
	'*************************************************************
	'过程作用：Lyfupload组件上传
	'*************************************************************
	Private Sub UpFile_1()
		Dim objLyf
		Dim ss
		Dim FileExt
		Dim filename
		Dim formPath
		Dim File_name
		Dim patharray
		Dim FileName_path
		Dim File_Ext
		Dim FormName
		Dim FormValue
		Set objLyf = Server.CreateObject("LyfUpload.UploadFile")
		For i = 1 To CInt(objLyf.Request("upcount"))
			If CInt(i) > 1 And CInt(DownsysClass.Setting(29)) = 0 Then
				Response.Write ("<script>alert('本系统没有开启批量上传功能!\n文件上传失败,请重新上传。');history.go(-1)</script>")
				Exit Sub
			End If
			If CInt(i) > CInt(DownsysClass.Setting(30)) Then
				Response.Write ("<script>alert('批量上传超过了限制!\n每次最多只能上传文件 " & CInt(DownsysClass.Setting(30)) & " 个。\n文件上传失败,请重新上传。');history.go(-1)</script>")
				Exit Sub
			End If
		Next
		objLyf.maxsize = CStr(UpFileSize) '上传文件大小
		objLyf.extname = UpFileType '上传文件类型
		For i = 1 To CInt(objLyf.Request("upcount"))
			FormValue = "upfile" & CInt(i)
			formPath = CreatePath(UpFilePath)
			FormName = objLyf.Request(FormValue)
			patharray = Split(FormName, """")
			If Len(patharray(1)) <> 0 Then
				FileName_path = Split(patharray(1), ".")
				'File_Ext = Split(FileName_path(UBound(FileName_path)), ".")
				FileExt = FileName_path(1)
			End If
			File_name = CreateName
			filename = File_name & "." & FileExt
			ss = objLyf.SaveFile(FormValue, Server.MapPath(UpFilePath & formPath), True, filename)
			If ss = "3" Then
				Response.Write ("<script>alert('文件名重复!');history.go(-1)</script>")
				Exit Sub
			ElseIf ss = "0" Then
				Response.Write ("<script>alert('文件尺寸过大!\n允许上传的文件大小：" & CStr(UpFileSize) / 1024 & " KB');history.go(-1)</script>")
				Exit Sub
			ElseIf ss = "1" Then
				Response.Write ("<script>alert('上传的文件类型不对!\n可以上传的文件类型如下\n" & UpFileType & "');history.go(-1)</script>")
				Exit Sub
			ElseIf ss = "" Then
				Response.Write ("<script>alert('您没有选择要上传的文件名，文件上传失败!');history.go(-1)</script>")
				Exit Sub
			Else
				UpFileUrl = UpFilePath & formPath & filename
				If CInt(i) <= CInt(UpNum) Then
					Call OutputScript(UpFileUrl, CInt(i))
				Else
					Response.Write ("<input type=""text"" name=""file1"" style=""width:100%"" value='" & UpFileUrl & "'> ")
					Response.Write ("文件上传成功! 文件大小: " & GetFileSize(objLyf.FileSize) & "&nbsp;&nbsp;[ <a href=# onclick=history.go(-1)>继续上传</a> ]")
				End If
			End If
		Next
		If CInt(objLyf.Request("upcount")) <= CInt(UpNum) Then
			Response.Write "<script language=javascript>alert('文件上传成功!');history.go(-1);</script>" & vbCrLf
		End If
		Set objLyf = Nothing
	End Sub

	Public Sub Init_UpFiles()
		Server.ScriptTimeOut = 99999
		NC_Admin.Check
		UpFileType = DownsysClass.Setting(27) & "|" & DownsysClass.Setting(25) '上传文件类型
		UpFileSize = (CStr(DownsysClass.Setting(23)) * 1024) + (CStr(DownsysClass.Setting(22)) * 1024) '上传文件大小
		UpFilePath = Session("NC_CurrentDir") '上传文件路径
		'*****************************************************************************
		'设置上传方式upload_type值： 0＝无组件，1＝lyfupload 1.2版
		'*****************************************************************************
		Upload_type = CInt(DownsysClass.Setting(28)) '默认设置上传组件
		'*****************************************************************************
		UploadFinish = False
		If NC_Admin.ChkAdmin("66", NC_Admin.Purview) = False Then
			Response.Write ("<script>alert('对不起!您没有上传文件的权限。');history.go(-1)</script>")
			Exit Sub
		End If
		Select Case Upload_type
			Case 0
				Call UpFiles_0
			Case 1
				Call UpFiles_1
			Case 999
				Response.Write ("<script>alert('本系统未开放上传功能!');history.go(-1)</script>")
				Exit Sub
			Case Else
				Response.Write ("<script>alert('本系统未开放上传功能!');history.go(-1)</script>")
				Exit Sub
				Response.End
		End Select
	End Sub
	'*************************************************************
	'过程作用：无组件上传类
	'*************************************************************
	Private Sub UpFiles_0()
		Dim objUpload
		Dim FormName
		Dim formdir
		Dim objFile
		Set objUpload = New Upload_Cls '建立上传对象
		objUpload.AutoSave = 1
		objUpload.FileType = UpFileType '上传文件类型
		objUpload.SavePath = UpFilePath '上传文件路径
		objUpload.FileSize = CStr(UpFileSize) '上传文件大小
		objUpload.UploadOpen '打开上传对象
		For i = 1 To UBound(objUpload.FileItem)
			If i > 1 And CInt(DownsysClass.Setting(29)) = 0 Then
				Response.Write ("<script>alert('本系统没有开启批量上传功能!\n文件上传失败,请重新上传。');history.go(-1)</script>")
				Exit Sub
			End If
			If i > CInt(DownsysClass.Setting(30)) Then
				Response.Write ("<script>alert('批量上传超过了限制!\n每次最多只能上传文件 " & CInt(DownsysClass.Setting(30)) & " 个。\n文件上传失败,请重新上传。');history.go(-1)</script>")
				Exit Sub
			End If
			FormName = objUpload.FileArray(CInt(i))
			Select Case objUpload.Form(FormName & "_Err")
	Case -1:
				Response.Write ("<script>alert('您没有选择要上传的文件名，文件上传失败!');history.go(-1)</script>")
				Exit Sub
	Case 0:
				Response.redirect (Request.ServerVariables("HTTP_REFERER"))
	Case 1:
				Response.Write ("<script>alert('文件尺寸过大!\n允许上传的文件大小：" & CStr(UpFileSize) / 1024 & " KB');history.go(-1)</script>")
				Exit Sub
	Case 2:
				Response.Write ("<script>alert('上传的文件类型不对!\n可以上传的文件类型如下\n" & UpFileType & "');history.go(-1)</script>")
				Exit Sub
	Case 3:
				Response.Write ("<script>alert('文件太大且格式不对，拒绝上传!\n可以上传的文件类型如下\n" & UpFileType & "\n允许上传的文件大小：" & CStr(DownsysClass.Setting(23)) & " KB');history.go(-1)</script>")
				Exit Sub
			End Select
		Next
		Set objUpload = Nothing
	End Sub
	'*************************************************************
	'过程作用：Lyfupload组件上传
	'*************************************************************
	Private Sub UpFiles_1()
		Dim objLyf
		Dim ss
		Dim FormValue
		Set objLyf = Server.CreateObject("LyfUpload.UploadFile")
		For i = 1 To CInt(objLyf.Request("upcount"))
			If i > 1 And CInt(DownsysClass.Setting(29)) = 0 Then
				Response.Write ("<script>alert('本系统没有开启批量上传功能!\n文件上传失败,请重新上传。');history.go(-1)</script>")
				Exit Sub
			End If
			If i > CInt(DownsysClass.Setting(30)) Then
				Response.Write ("<script>alert('批量上传超过了限制!\n每次最多只能上传文件 " & CInt(DownsysClass.Setting(30)) & " 个。\n文件上传失败,请重新上传。');history.go(-1)</script>")
				Exit Sub
			End If
		Next
		objLyf.maxsize = CStr(UpFileSize) '上传文件大小
		objLyf.extname = UpFileType '上传文件类型
		For i = 1 To CInt(objLyf.Request("upcount"))
			FormValue = "upfile" & CInt(i)
			ss = objLyf.SaveFile(FormValue, Server.MapPath(UpFilePath), True)
			If ss = "3" Then
				Response.Write ("<script>alert('文件名重复!');history.go(-1)</script>")
				Exit Sub
			ElseIf ss = "0" Then
				Response.Write ("<script>alert('文件尺寸过大!\n允许上传的文件大小：" & CStr(UpFileSize) / 1024 & " KB');history.go(-1)</script>")
				Exit Sub
			ElseIf ss = "1" Then
				Response.Write ("<script>alert('上传的文件类型不对!\n可以上传的文件类型如下\n" & UpFileType & "');history.go(-1)</script>")
				Exit Sub
			ElseIf ss = "" Then
				Response.Write ("<script>alert('您没有选择要上传的文件名，文件上传失败!');history.go(-1)</script>")
				Exit Sub
			Else
				UploadFinish = True
			End If
		Next
		Response.redirect (Request.ServerVariables("HTTP_REFERER"))
		Set objLyf = Nothing
	End Sub
	'*************************************************************
	'过程作用：输出客户端脚本
	'*************************************************************
	Private Sub OutScript(Str)
		Response.Write "<script language=javascript>" & Str & ";history.back()</script>"
	End Sub

	Private Sub OutputScript(Str, ID)
		Response.Write "<script language=javascript>" & vbCrLf
		Response.Write "parent.document.myform.image" & ID & ".value='" & Str & "';" & vbCrLf
		Response.Write "</script>" & vbCrLf
	End Sub
	'*************************************************************
	'函数作用：按月份自动上传文件夹,需要ＦＳＯ组件支持
	'*************************************************************
	Private Function CreatePath(formPath)
		Dim objFSO
		Dim Fsofolder
		Dim uploadpath
		uploadpath = Year(Now) & "-" & Month(Now) '以年月创建上传文件夹，格式：2003－8
		On Error Resume Next
		Set objFSO = CreateObject("Scripting.FileSystemObject")
		If objFSO.FolderExists(Server.MapPath(formPath & uploadpath)) = False Then
			objFSO.CreateFolder Server.MapPath(formPath & uploadpath)
		End If
		If Err.Number = 0 Then
			CreatePath = uploadpath & "/"
		Else
			CreatePath = ""
		End If
		Set objFSO = Nothing
	End Function
	'*************************************************************
	'函数作用：文件名更名
	'*************************************************************
	Private Function CreateName()
		Dim ranNum
		Randomize
		ranNum = Int(999 * Rnd)
		CreateName = Year(Now) & Month(Now) & Day(Now) & Hour(Now) & Minute(Now) & Second(Now) & ranNum
	End Function
	'*******************************************
	'函数作用：格式化文件的大小
	'*******************************************
	Private Function GetFileSize(Size)
		Dim FileSize
		FileSize = Size / 1024
		FileSize = FormatNumber(FileSize, 2)
		If FileSize < 1024 And FileSize > 1 Then
			GetFileSize = "<font color=red><B>" & FileSize & "</B></font>&nbsp;KB"
		ElseIf FileSize > 1024 Then
			GetFileSize = "<font color=red><B>" & FormatNumber(FileSize / 1024, 2) & "</B></font>&nbsp;MB"
		Else
			GetFileSize = "<font color=red><B>" & Size & "</B></font>&nbsp;Bytes"
		End If
	End Function

End Class
%>
