📄 addattachdo.asp
字号:
<!--#include file ="../../Include/DataEnvi.asp"-->
<!--#include file ="../../Include/function.asp"-->
<%
Path = Server.MapPath("../../Upload/OA/Mail")
Name = Session("AccountID")
If Not IsExistFold(Path,Name) Then
UserFold = CreateFold(Path,Name)
' Response.Write "Here1"
Else
' Response.Write "Here2"
UserFold = "../../Upload/OA/Mail/" & Name
UserFold = Server.MapPath(UserFold)
End If
%>
<%
Dim ObjDB,ObjRS,StrSQL
Dim strFileName,IntMsgID
Dim StrContentType,IntID
Dim ObjPic,PicType
Dim Source
Set ObjPic = Server.CreateObject("LyfUpload.UploadFile")
' ObjPic.MaxSize = 601440 '设置文件上传的最大为2048个字节(2K)
IntFileSize = 0
IntMsgID = ObjPic.Request("IntMsgID")
StrContentType = ObjPic.FileType("source")
strFileName = ObjPic.Request("attachName")
Source = ObjPic.Request("source")
Set ObjDB = Server.CreateObject("Adodb.Connection")
OpenDB ObjDB
Set ObjRS = Server.CreateObject("Adodb.Recordset")
strSQL = "select ID,BasePath from t_OA_Message_Attach Where MessageID=" & IntMsgID
ObjRS.Open strSQL,objDB,1,3
Path = UserFold
If ObjRS.EOF Then
Path = UserFold
Name = Year(Date()) & Month(Date()) & Day(Date())
Name = Name & Hour(Time()) & Minute(Time()) & Second(Time())
MyValue = 0
Do While MyValue<10000
Randomize
MyValue = CLng(100000*Rnd)
Loop
Name = Name & MyValue
BasePath = Name
Fold = CreateFold(Path,Name)
Else
BasePath = ObjRS.Fields("BasePath")
Name = ObjRS.Fields("BasePath")
Fold = Path & "\" & Name
' Fold = server.MapPath(Fold)
End If
ObjRS.Close()
' Response.Write "Fold = " & Fold
' Response.End
StrSQL = "Select * From t_OA_Message_Attach"
ObjRS.Open StrSQL,ObjDB,1,3
ObjRS.AddNew
ObjRS("BasePath") = BasePath
objRS("MessageID") = IntMsgID
objRS("FileName") = strFileName
ObjRS("ContentType") = StrContentType
ObjRS("ExtName") = GetExtName(Source)
objRS("CreateTime") = Now()
ObjRS.Update
IntID = ObjRS("ID")
ObjRS.Close()
' Response.Write Fold
IntSaveRe = ObjPic.SaveFile("source",Fold,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_Message_Attach Set FileSize = " & IntFileSize & " Where ID = " & IntID
ObjDB.Execute StrSQL
StrSQL = "Update t_OA_Message_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 GetFileName(IntmyID,mySource)
Dim FileName,extName,subSign,upSign,extLen
subSign = InStr(mySource,".") + 1
upSign = InStr(mySource,"C") - 4
extLen = upSign - subSign + 1
extName = Mid(mySource,subSign,extLen)
FileName = IntmyID & "." & extName
GetFileName = FileName
End Function
Function GetExtName(mySource)
Dim FileName,extName,subSign,upSign,extLen
subSign = InStr(mySource,".") + 1
upSign = InStr(mySource,"C") - 4
extLen = upSign - subSign + 1
extName = Mid(mySource,subSign,extLen)
GetExtName = extName
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -