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

📄 upfile.asp

📁 企业办公简单管理系统,可以发布信息以及论坛
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include FILE="upload_5xsoft.asp"-->
<!-- #include file="conn/logors.asp" -->
<%
function GetExtendName(FileName)
	dim ExtName
	ExtName = LCase(FileName)
	ExtName = right(ExtName,3)
	ExtName = right(ExtName,3-Instr(ExtName,"."))
	GetExtendName = ExtName
end function

''将当前的日期和时间转为文件名
function makefilename(fname)
	fname = now()
  	fname = replace(fname,"-","")
	fname = replace(fname," ","") 
	fname = replace(fname,":","")
	fname = replace(fname,"PM","")
	fname = replace(fname,"AM","")
	fname = replace(fname,"上午","")
	fname = replace(fname,"下午","")
	makefilename=fname
end function 

if Request.TotalBytes>1 then

	dim upload,file,formName,iCount,msgcount,msginfo
	
	FileMaxSize=5*1024*1024
	FileType="jpggifdocrartxtxls"
	UpFilePath="doc/"
	fname=""
	iCount=0
	msgcount=0
	msginfo=""
	
	set upload=new upload_5xSoft ''建立上传对象
	
	for each formName in upload.file ''列出所有上传了的文件
		set file=upload.file(formName)  ''生成一个文件对象
		if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
			if file.FileSize<FileMaxSize then ''如果未超过文件大小限制
				if Instr(FileType,GetExtendName(file.FileName)) then
					TypeFlag = 1        '文件为允许的类型
				else
					TypeFlag = 0		'文件为不允许的类型
					msgcount=msgcount+1
					msginfo=msginfo & msgcount & "、不支持您所上传的文件类型:" & GetExtendName(file.FileName) & "<br>"
				end if
	
				if TypeFlag = 1 then 
					vfname = makefilename(now())
					fname = vfname & "." & GetExtendName(file.FileName)
					icount=icount+1
				
					file.SaveAs Server.mappath(UpFilePath&fname)   ''保存文件
					
				end if
			else
				msgcount=msgcount+1
				msginfo=msginfo & msgcount & "、文件大小超出限制,您最多可以上传 "& FileMaxSize &"个字节的文件数据<br>"
				exit for
			end if
		end if
		set file=nothing
	next


	if iCount>0 then
		msgcount=msgcount+1
		msginfo=msginfo &msgcount & "、成功上传文件数:"&iCount&" 个文件!<br>"
	elseif fname<>"" then
		msgcount=msgcount+1	
		msginfo=msginfo &msgcount & "、上传文件失败,请确定你选择了源文件所在目录或上传的是所许可的文件格式!<br>"
	end if

	set rssave=createobject("adodb.recordset") 
	
	if upload.form("saveflag")="1" then
		sql="select max(id) as maxid from cci_oa_file "
		set rs1=connobj.execute(sql)
		if not rs1.eof then
			maxid=rs1("maxid")
			if isnull(maxid) then
				maxid=0
			end if
		else
			maxid=0
		end if
		rs1.close
		
		maxid=maxid+1
		
		sql="select * from cci_oa_file"
		rssave.Open sql,connObj,3,3
		rssave.addnew
	
		rssave("id")=maxid
		rssave("title")=upload.form("title")
		rssave("userid")=session("userid")
		if fname<>"" then
			rssave("filename")=fname
		end if
		rssave("sendtime")=now
		rssave("memo")=upload.form("memo")
		
		rssave.update
		rssave.close
		set rssave=nothing
		
		sql="insert into cci_oa_filedest(srcid,userid,status) values(" & maxid & ","& upload.form("userid") & ",0)"
		connObj.execute(sql)
				
		msgcount=msgcount+1
		msginfo=msginfo & msgcount & "、信息发送保存成功!<br>" 
		
	end if
	set upload=nothing  ''删除此对象
	response.Redirect "message.asp?rediurl=send.asp&msgurl=公文发送&msginfo=" & msginfo
end if

%>

⌨️ 快捷键说明

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