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

📄 post_upfile.asp

📁 品泡女人香XI8.NET文章管理系统的源码
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<!--#include File="conn.asp"-->
<!--#include File="upload.inc"-->
<!-- #include File="inc/const.asp" -->
<!-- #include File="inc/dv_clsother.asp" -->
<script>
parent.document.Dvform.Submit.disabled=false;
parent.document.Dvform.Submit2.disabled=false;
</script>
<table width="100%" height="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class=tablebody2 valign=top height=40>
<%
Dvbbs.Loadtemplates("")
Dvbbs.Head()
Call Dvbbs.ShowErr()
Server.ScriptTimeOut=999999'要是你的论坛支持上传的文件比较大,就必须设置。
Dim upload_type,upload_ViewType
'-----------------------------------------------------------------------------
'设置上传方式upload_type值: 0=无组件,1=lyfupload 1.2版,2=Aspupload3.0,3=SA-FileUp 4.0,4=DvFile.Upload V1.0
'-----------------------------------------------------------------------------
upload_type=Cint(Dvbbs.Forum_Setting(43))
'-----------------------------------------------------------------------------
'创建生成预览图片,需要图片读写组件支持.(根目录下要有PreviewImage文件夹存放文件)
'设置支持组件upload_ViewType值: 
'0= CreatePreviewImage, 1= AspJpeg ,2=SoftArtisans ImgWriter V1.21,3=SJCatSoft V2.6 
Dim previewpath,F_Viewname
F_Viewname=""
previewpath="PreviewImage/"
upload_ViewType=Cint(Dvbbs.Forum_Setting(45))
'-----------------------------------------------------------------------------
'提交验证
If Not Dvbbs.ChkPost Then
	Response.End
End If
If Dvbbs.Userid=0 Then
	Response.write "你还未登陆!"
	Response.End
End If

DateUpNum=Clng(Dvbbs.UserToday(2))
UpNum=request.cookies("upNum")
If UpNum ="" then UpNum=0
UpNum=int(UpNum)

If Cint(Dvbbs.GroupSetting(7))=0 then
	Response.write "您没有在本论坛上传文件的权限"
	Response.End
End If
If upNum >= Clng(Dvbbs.GroupSetting(40)) then
 	Response.write "一次只能上传"&Dvbbs.GroupSetting(40)&"个文件!"
	Response.End
End If
If dateupnum+upNum >= Clng(Dvbbs.GroupSetting(50)) then
 	Response.write "您今天上传的文件已超出了"&Dvbbs.GroupSetting(50)&"个!"
	Response.End
End If
'-----------------------------------------------------------------------------
'定义变量
Dim Forumupload
Dim FormName,FormPath,Filename,File_name,FileExt,Filesize,F_Type,rename
Dim upNum,dateupnum
Dim TempSize,ImageWidth,ImageHeight
Dim ImageMode
ImageMode=Dvbbs.Forum_Setting(73)
If ImageMode="0" Then ImageMode=""
ImageWidth=80
ImageHeight=80
TempSize=Split(Dvbbs.Forum_Setting(72),"|")
If Ubound(TempSize)=1 Then
	ImageWidth=TempSize(0)
	ImageHeight=TempSize(1)
End If
FormPath=CheckFolder&CreatePath()	'上传目录路径

'On Error Resume Next 
Select case upload_type
	Case 0
		Call upload_0()
	Case 1
		Call upload_1()
	Case 2
		Call upload_2()
	Case 3
		Call upload_3()
	Case 4
		Call upload_4()
	Case Else
		Response.write "本系统未开放插件功能"
		Response.End
End Select

'===========================无组件上传============================
Sub upload_0()
	Dim upload,File,UpCount
	UpCount=0
	Set upload = new UpFile_Class						''建立上传对象
	Upload.InceptFileType = Replace(Dvbbs.Board_Setting(19),"|",",")
	Upload.MaxSize = Int(Dvbbs.GroupSetting(44))*1024
	Upload.GetDate ()	'取得上传数据
	If upload.err > 0 then
		Select Case upload.err
		Case 1
			Response.write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
		Case 2
			Response.write "文件大小超过了限制 "&Dvbbs.GroupSetting(44)&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
		Case 3
			Response.write "文件类型不正确 "&Dvbbs.GroupSetting(44)&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
		End Select
		Exit Sub
	Else
		For Each FormName In upload.File		''列出所有上传了的文件
			If upNum >= Int(Dvbbs.GroupSetting(40)) or dateupnum+upNum >= clng(Dvbbs.GroupSetting(50)) then
				Response.write "已达到上传数的上限。"
				EXIT SUB
			End If
			Set File=upload.File(FormName)		''生成一个文件对象
			FileExt=FixName(File.FileExt)
			'判断文件类型
			If CheckFileExt(FileExt)=false then
				Response.write "文件格式不正确,或不能为空 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
				EXIT SUB
			End If
			'付值变量
			F_Type		=	CheckFiletype(FileExt)
			File_name	=	CreateName()
			Filename	=	File_name&"."&FileExt
			rename		=	CreatePath&Filename&"|"
			Filename	=	FormPath&Filename
			Filesize	=	File.FileSize
			'记录文件
			If Filesize>0 then								'如果 FileSize > 0 说明有文件数据
			File.SaveToFile Server.mappath(FileName)		''执行上传文件
			'创建生成预览图片
				If upload_ViewType<>999 and F_Type=1 then
					F_Viewname=previewpath&"pre"&File_name&".jpg"
					Call CreateView(FileName,F_Viewname)
				End If
			'记录文件
			Call checksave()
			UpCount=UpCount+1
			End If
			Set File=Nothing
		Next
	End If
	Set upload=Nothing
	Call Suc_upload(UpCount,upNum)
End Sub

''===========================lyfupload组件上传1.2版============================
Sub upload_1()
	Dim obj,Filepath,FileExt_a,UpCount
	Dim ss,i
	Dim TempExt,TempFileValue
	UpCount=0
	Set obj = Server.CreateObject("LyfUpload.UploadFile")
	'限制大小
	obj.maxsize=Int(Dvbbs.GroupSetting(44))*1024
	'限制类型
	obj.extname=Replace(Dvbbs.Board_Setting(19),"|",",")
	Filepath=Server.MapPath(FormPath)
	'在目录后加(/)
	If Right(Filepath,1)<>"\" Then Filepath=Filepath&"\"
	For i=1 to obj.Request("upcount")
	 TempFileValue	=	"file"&i
		FileExt_a	=	Split(obj.Request(TempFileValue),"""")
		TempExt		=	FileExt_a(1)
		If TempExt="" or isnull(TempExt) then
			Response.write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
			Exit Sub
		End If
		FileExt		=	Mid(TempExt, InStrRev(TempExt, ".")+1)
		FileExt		=	FixName(FileExt)
		File_name	=	CreateName()
		Filename	=	File_name&"."&FileExt
		rename		=	CreatePath&Filename & "|"
		Filesize	=	obj.Filesize
		'判断文件类型及付值变量
		F_Type		=CheckFiletype(FileExt)

		'判断文件类型
		If CheckFileExt(FileExt)=False then
			Response.write "文件格式不正确,或不能为空 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
			EXIT SUB
		End If
		'保存文件
		ss=obj.SaveFile(TempFileValue,Server.MapPath(FormPath), false,Filename)
		If ss= "3" then
			Response.write ("文件名重复! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
			EXIT SUB
		ElseIf ss= "0" then
			Response.write ("文件大小超过了限制 "&Dvbbs.GroupSetting(44)&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
			EXIT SUB
		ElseIf ss = "1" then
			Response.write ("文件不是指定类型文件! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
			EXIT SUB
		ElseIf ss = "" then
			Response.write ("文件上传失败! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
			EXIT SUB
		Else
			Filename=FormPath&Filename
			'创建生成预览图片
			If upload_ViewType<>999 and F_Type=1 then
				F_Viewname=previewpath&"pre"&File_name&".jpg"
				call CreateView(FileName,F_Viewname)
			End If
			'记录文件
			call checksave()
			UpCount=UpCount+1
		End If
	Next
	set obj=nothing
	Call Suc_upload(UpCount,upNum)
End Sub

''===========================Aspupload3.0组件上传============================
sub upload_2()
	On Error Resume Next
	Dim Upload,File
	Dim FilePath
	Dim Count,UpCount
	UpCount=0
	Set Upload = Server.CreateObject("Persits.Upload") 
	Upload.OverwriteFiles = false								'不能复盖
	Upload.IgnoreNoPost = True
	Upload.SetMaxSize Int(Dvbbs.GroupSetting(44))*1024, True	'限制大小
	Count = Upload.Save
	If Err.Number = 8 Then 
	   Response.write "文件大小超过了限制 "&Dvbbs.GroupSetting(44)&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]" 
	Else 
		If Err <> 0 Then 
			Response.write "错误信息: " & Err.Description
			EXIT SUB
		Else
			If Count < 1 Then 
				Response.write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
				EXIT SUB
			End If
		For Each File in Upload.Files	'列出所有上传文件
			If upNum >= Int(Dvbbs.GroupSetting(40)) or dateupnum+upNum >= Clng(Dvbbs.GroupSetting(50)) Then
				Response.write "已达到上传数的上限。"
				Exit Sub
			End If
			FileExt = Replace(File.ext,".","")
			FileExt = FixName(FileExt)
			'判断文件类型
			If CheckFileExt(FileExt)=False then
				Response.write "文件格式不正确,或不能为空 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
				EXIT SUB
			End If
			'文件变量付值
			File_name	=	CreateName()
			Filename	=	File_name&"."&FileExt
			rename		=	CreatePath&Filename & "|"
			Filename	=	FormPath&Filename
			Filesize	=	File.Size
			F_Type		=	CheckFiletype(FileExt)
			File.saveas Server.MapPath(Filename)	'上传保存文件
			'创建生成预览图片
			If upload_ViewType<>999 and F_Type=1 then
				F_Viewname=previewpath&"pre"&File_name&".jpg"
				Call CreateView(FileName,F_Viewname)
			End If
			'记录文件
			Call checksave()			'记录文件
			UpCount=UpCount+1
		Next
		Call Suc_upload(UpCount,upNum)
		End If 
	End If
	Set Upload = Nothing
End Sub

''===========================SA-FileUp 4.0组件上传FileUpSE V4.09============================
sub upload_3()
	Dim oFileUp,UpCount,FileExt_a
	UpCount=0
	Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")
	'oFileUp.Path = Server.MapPath(FormPath)
	For Each FormName In oFileUp.Form
		If IsObject(oFileUp.Form(FormName)) Then
			If Not oFileUp.Form(FormName).IsEmpty Then
				oFileUp.Form(FormName).Maxbytes=int(Dvbbs.GroupSetting(44))*1024	'限制大小
				Filesize=oFileUp.Form(FormName).TotalBytes
				If Filesize>int(Dvbbs.GroupSetting(44))*1024 then
					Response.write "文件大小超过了限制 "&Dvbbs.GroupSetting(44)&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]" 
					Exit sub
				End If
				Filename	= oFileUp.Form(FormName).ShortFileName	 '原文件名
				FileExt		= Mid(Filename, InStrRev(Filename, ".")+1)
				FileExt		= FixName(FileExt)
				'判断文件类型
				If CheckFileExt(FileExt)=false then
					Response.write "文件格式不正确,或不能为空 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
					Exit Sub
				End If
				'文件变量付值
				File_name	=	CreateName()
				Filename	=	File_name&"."&FileExt
				rename		=	CreatePath&Filename & "|"
				Filename	=	FormPath&Filename
				F_Type		=	CheckFiletype(FileExt)
				
				'保存文件
				oFileUp.Form(FormName).Saveas Server.MapPath(Filename)
				'创建生成预览图片
				If upload_ViewType<>999 and F_Type=1 then
					F_Viewname=previewpath&"pre"&File_name&".jpg"
					Call CreateView(FileName,F_Viewname)
				End If
				'记录文件
				Call checksave()			'记录文件
				UpCount	= UpCount+1
			Else
				Response.write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
				EXIT SUB
			End If
		End If
	Next
	Set oFileUp = Nothing
	Call Suc_upload(UpCount,upNum)
End Sub

'===========================DvFile.Upload V1.0组件上传============================
Sub upload_4()
	Dim upload,File,UpCount
	UpCount=0
	Set upload = Server.CreateObject("DvFile.Upload")			''建立上传对象
	Upload.InceptFileType = Replace(Dvbbs.Board_Setting(19),"|",",")
	Upload.MaxSize = Int(Dvbbs.GroupSetting(44))*1024
	Upload.Install		'取得上传数据

⌨️ 快捷键说明

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