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

📄 nc_upfilecls_user.asp

📁 大型黄页系统,精美黄页flash演示,10m
💻 ASP
📖 第 1 页 / 共 2 页
字号:
			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 DownsysClass.memberName = "Empty"  Then
			Response.Write ("<script>alert('对不起!您没有上传文件的权限3。');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" & upnum & ".value='" & Str & "';" & vbCrLf
		Response.Write "</script>" & vbCrLf
	End Sub
	'*************************************************************
	'函数作用:按月份自动上传文件夹,需要FSO组件支持
	'*************************************************************
	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
%>

⌨️ 快捷键说明

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