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

📄 addattachdo.asp

📁 功能齐全的oa系统
💻 ASP
字号:
<!--#include virtual ="/Include/DataEnvi.asp"-->
<%
	Dim ObjDB,ObjRS,StrSQL
	Dim strFileName,IntComMsgID
	Dim StrContentType,IntID
	Dim ObjPic,PicType
	Dim Source
	
	Set ObjPic = Server.CreateObject("LyfUpload.UploadFile")
	
'	ObjPic.MaxSize = 601440  '设置文件上传的最大为2048个字节(2K)

	IntFileSize = 0
	IntComMsgID	= ObjPic.Request("ComMsgID")
	StrContentType = ObjPic.FileType("source")
	strFileName = ObjPic.Request("attachName")
	Source		= ObjPic.Request("source")
'	Response.Write source 
'	Response.End 
	
	Set ObjDB = Server.CreateObject("Adodb.Connection")
	OpenDB ObjDB
	Set ObjRS = Server.CreateObject("Adodb.Recordset")
	
	StrSQL	= "Select * From t_OA_Work_ComMessage_Attach"

	ObjRS.Open StrSQL,ObjDB,1,3
	
	ObjRS.AddNew 
	objRS("ComMsgID")	 = IntComMsgID
	objRS("AttachName")  = strFileName
	ObjRS("ContentType")	= StrContentType
	objRS("CreateTime") = Now()
	ObjRS.Update
	IntID = ObjRS("ID")
	ObjRS.Close()
	
	IntSaveRe = ObjPic.SaveFile("source",Server.MapPath("Attach"),true,GetFileName(IntID,Source)) '保存文件到服务器
	IntFileSize	 = ObjPic.FileSize 
	

	
	If IntSaveRe = "" Then
		StrErr = "文件上传失败!"
	ElseIf IntSaveRe = "0"  Then
		StrErr = "文件尺寸过大!"
	ElseIf IntSaveRe = "1" Then
		StrErr = "文件不是jpg文件!"
	Else
		StrSQL = "Update t_OA_Work_ComMessage_Attach Set AttachSize = " & IntFileSize & " Where ID = " & IntID
		ObjDB.Execute StrSQL 
		StrSQL = "Update t_OA_Work_ComMessage_Attach Set IsUpSuccess = 1 Where ID = " & IntID
		ObjDB.Execute StrSQL 
	End if

	If StrErr <> "" Then
		Response.Write "<script language=javascript>alert('" & StrErr & "');window.history.go(-1)</script>"
	Else
		Response.Write "<script language=javascript>window.history.go(-1)</script>"
	End If
	
	Function GetExtName(mySource)
	'	Dim extName,subSign,upSign,extLen
	'	Response.Write 	InStr(mySource,"Content-Type")-4 & "<br>"
	'	Response.Write Mid(mySource,1,InStr(mySource,"Content-Type")-4)	& "<br>"
	'	Response.Write InStrRev(Mid(mySource,1,InStr(mySource,"Content-Type")-4), ".") & "<br>"
		GetExtName =  Mid(Mid(mySource,1,InStr(mySource,"Content-Type")-4),InStrRev(Mid(mySource,1,InStr(mySource,"Content-Type")-4), ".")+1)
	End Function
	Function GetFileName(IntmyID,mySource)
		Dim FileName,extName
		extName = GetExtName(mySource)
		FileName	=	IntmyID & "." & extName
		GetFileName	=	FileName
	'	Response.Write subSign & "---" & upSign & "--" & extLen & "--" & extName & "--" & FileName
	End Function
%>

⌨️ 快捷键说明

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