📄 powereasy.upfile.asp
字号:
SavePath = InstallDir & rsChannel("ChannelDir") & "/" & UploadDir
Select Case FileType
Case "pic", "batchpic", "softpic", "intervieweepic"
UpFileType = Trim(arrFileType(0))
Case "photo", "photos"
UpFileType = Trim(arrFileType(0)) & "|" & Trim(arrFileType(1))
Case "flash"
UpFileType = Trim(arrFileType(1))
Case "media"
UpFileType = Trim(arrFileType(2))
Case "real"
UpFileType = Trim(arrFileType(3))
Case "fujian"
UpFileType = Trim(arrFileType(4))
Case "soft"
UpFileType = Trim(arrFileType(1)) & "|" & Trim(arrFileType(2)) & "|" & Trim(arrFileType(3)) & "|" & Trim(arrFileType(4))
Case Else
UpFileType = ""
End Select
If fso.FolderExists(Server.MapPath(InstallDir & rsChannel("ChannelDir"))) = False Then fso.CreateFolder Server.MapPath(InstallDir & rsChannel("ChannelDir"))
If fso.FolderExists(Server.MapPath(SavePath)) = False Then fso.CreateFolder Server.MapPath(SavePath)
End If
rsChannel.Close
Set rsChannel = Nothing
End If
If uEnableUpload = False Then EnableUploadFile = False
If MaxFileSize > uMaxFileSize Then MaxFileSize = uMaxFileSize
If EnableUploadFile = False Then
Response.Write "本频道未开放文件上传功能"
FoundErr = True
End If
If FoundErr = True Then Exit Sub
Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<title>上传文件结果</title>" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
Response.Write "<link rel='stylesheet' type='text/css' href='../Editor/editor_dialog.css'>" & vbCrLf
Response.Write "</head>" & vbCrLf
Response.Write "<body leftmargin='5' topmargin='0'>" & vbCrLf
Dim EnableUpload, msg
Dim AddWatermark, EnableCreateThumb, ThumbWidth, ThumbHeight, LinkUrl
Dim strJS, dtNow, ranNum, strFileName, strThumbPath, i
Dim strTemp, FileCount, strUploadPics
Dim FormNames
Dim oFileInfo
Dim cFileName, cFilePath, cFileExt, cFileMIME, cFileStart, cFileSize
Dim oFilestream
Dim PE_Thumb
Set PE_Thumb = New CreateThumb
FileCount = 0
FormNames = Files.Keys
LinkUrl = LCase(Trim(Forms("LinkUrl")))
IsThumb = Trim(Forms("IsThumb"))
If IsNumeric(IsThumb) Then
IsThumb = CLng(IsThumb)
Else
IsThumb = 0
End If
For i = 0 To Files.Count - 1
EnableUpload = False
dtNow = Now()
oFileInfo = Files.Item(FormNames(i))
cFileName = oFileInfo(1)
cFilePath = oFileInfo(2)
cFileExt = oFileInfo(3)
cFileMIME = oFileInfo(4)
cFileStart = oFileInfo(5)
cFileSize = oFileInfo(6)
If cFileSize < 10 Then
FoundErr = True
If Not (FileType = "batchpic" Or FileType = "photos") Then
msg = "请先选择你要上传的文件!"
End If
Else
If cFileSize > (MaxFileSize * 1024) Then
If FileType = "batchpic" Then
Response.Write "<li>第 " & i + 1 & " 个文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!</li>"
Else
msg = "文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!"
End If
FoundErr = True
Else
If CheckFileExt(UpFileType, cFileExt) = False Or CheckFileExt(NoAllowExt, cFileExt) = True Or IsValidStr(cFileExt) = False Then
FoundErr = True
If cFileName <> "" Then
If (FileType = "batchpic" Or FileType = "photos") Then
Response.Write "<li>第 " & i + 1 & " 个文件不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType & "</li>"
Else
msg = "这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType
End If
End If
Else
If Left(LCase(cFileMIME), 5) = "text/" And CheckFileExt(NeedCheckFileMimeExt, cFileExt) = True Then
FoundErr = True
If (FileType = "batchpic" Or FileType = "photos") Then
Response.Write "<li>第 " & i + 1 & " 个文件是用文本文件伪造的图片文件或压缩文件,为了系统安全,不允许上传这种类型的文件!</li>"
Else
msg = "为了系统安全,不允许上传用文本文件伪造的图片文件!"
End If
Else
EnableUpload = True
End If
End If
End If
End If
If EnableUpload = True Then
dirMonth = Year(dtNow) & Right("0" & Month(dtNow), 2) & "/"
tmpPath = SavePath & dirMonth
If FileType = "adminblogpic" Or FileType = "userblogpic" Then
If fso.FolderExists(Server.MapPath(SavePath)) = False Then fso.CreateFolder Server.MapPath(SavePath)
End If
If fso.FolderExists(Server.MapPath(tmpPath)) = False Then fso.CreateFolder Server.MapPath(tmpPath)
Randomize
strFileName = GetNumString()
tmpPath = tmpPath & strFileName & "." & cFileExt
Set oFilestream = Server.CreateObject("ADODB.Stream")
oFilestream.Type = 1
oFilestream.Mode = 3
oFilestream.Open
oUpFilestream.Position = cFileStart
oUpFilestream.CopyTo oFilestream, cFileSize
oFilestream.SaveToFile Server.MapPath(tmpPath) '保存文件
oFilestream.Close
Set oFilestream = Nothing
FileCount = FileCount + 1
Select Case FileType
Case "batchpic"
Response.Write "<li>第 " & i + 1 & " 张图片上传成功!"
If LinkUrl <> "" And LinkUrl <> "http://" Then strTemp = strTemp & "<a href='" & LinkUrl & "' target='_blank'>"
strTemp = strTemp & "<img src='" & tmpPath & "'alt='" & Trim(Forms("alttext" & i)) & "'"
If Trim(Forms("width" & i)) <> "" Then strTemp = strTemp & "width='" & PE_CLng(Trim(Forms("width" & i))) & "'"
If Trim(Forms("height" & i)) <> "" Then strTemp = strTemp & "height='" & PE_CLng(Trim(Forms("height" & i))) & "'"
strTemp = strTemp & " border='" & PE_CLng(Trim(Forms("border" & i))) & "'"
strTemp = strTemp & " style='BORDER-COLOR:" & Trim(Forms("bordercolor" & i)) & "'"
strTemp = strTemp & " align='" & Trim(Forms("aligntype" & i)) & "'"
If Trim(Forms("vspace" & i)) <> "" Then strTemp = strTemp & " vspace='" & PE_CLng(Trim(Forms("vspace" & i))) & "'"
If Trim(Forms("hspace" & i)) <> "" Then strTemp = strTemp & " hspace='" & PE_CLng(Trim(Forms("hspace" & i))) & "'"
If Trim(Forms("styletype" & i)) <> "" Then strTemp = strTemp & " style='filter:" & Trim(Forms("styletype" & i)) & "'"
If Trim(Forms("zoom" & i)) = "Yes" Then
strTemp = strTemp & " onload='resizepic(this)' onmousewheel='return bbimg(this)'"
End If
strTemp = strTemp & ">"
If LinkUrl <> "" And LinkUrl <> "http://" Then strTemp = strTemp & "</a>"
strTemp = strTemp & "<BR><BR>"
strUploadPics = strUploadPics & "$$$" & dirMonth & strFileName & "." & cFileExt
If Trim(Forms("AddWatermark" & i)) = "Yes" Then
AddWatermark = True
Else
AddWatermark = False
End If
If Trim(Forms("CreateThumb" & i)) = "Yes" Then
EnableCreateThumb = True
Else
EnableCreateThumb = False
End If
ThumbWidth = PE_CLng(Trim(Forms("ThumbWidth" & i)))
ThumbHeight = PE_CLng(Trim(Forms("ThumbHeight" & i)))
If PhotoObject > 0 And EnableCreateThumb = True Then
strThumbPath = SavePath & dirMonth & strFileName & "_S." & cFileExt
If PE_Thumb.CreateThumb(tmpPath, strThumbPath, ThumbWidth, ThumbHeight) = True Then
FileCount = FileCount + 1
strUploadPics = strUploadPics & "$$$" & dirMonth & strFileName & "_S." & cFileExt
Response.Write " <FONT color='green'> 创建缩略图成功!</FONT> "
End If
End If
If PhotoObject > 0 And AddWatermark = True Then
If PE_Thumb.AddWatermark(tmpPath) = True Then
Response.Write " <FONT color='blue'>生成水印成功!</font> "
End If
End If
Response.Write "</li>"
Case "pic"
strUploadPics = dirMonth & strFileName & "." & cFileExt
If PhotoObject > 0 Then
strThumbPath = SavePath & dirMonth & strFileName & "_S." & cFileExt
If PE_Thumb.CreateThumb(tmpPath, strThumbPath, 0, 0) = True Then
strUploadPics = strUploadPics & "$$$" & dirMonth & strFileName & "_S." & cFileExt
FileCount = FileCount + 1
End If
Call PE_Thumb.AddWatermark(tmpPath)
End If
Response.Write "图片上传成功! <a href='upload.asp?DialogType=" & FileType & "&ChannelID=" & ChannelID & "&PhotoUpfileType=" & PE_CLng(Trim(Forms("PhotoUpfileType"))) & "'>继续上传</a>" & vbCrLf
strJS = strJS & "parent.url.value='" & tmpPath & "';" & vbCrLf
strJS = strJS & "parent.frmPreview.img.src='" & tmpPath & "';" & vbCrLf
strJS = strJS & "parent.frmPreview.img2.src='" & tmpPath & "';" & vbCrLf
strJS = strJS & "parent.upfilename.value='" & FileCount & "$$$" & strUploadPics & "';" & vbCrLf
Exit For
Case "flash", "media", "real", "fujian"
Response.Write "文件上传成功! <a href='upload.asp?DialogType=" & FileType & "&ChannelID=" & ChannelID & "&PhotoUpfileType=" & PE_CLng(Trim(Forms("PhotoUpfileType"))) & "'>继续上传</a>" & vbCrLf
strJS = strJS & "parent.document.form1.url.value='" & SavePath & dirMonth & strFileName & "." & cFileExt & "';" & vbCrLf
strJS = strJS & "parent.document.form1.UpFileName.value='" & dirMonth & strFileName & "." & cFileExt & "';" & vbCrLf
Exit For
Case "photos"
Response.Write "<li>第 " & i + 1 & " 张图片上传成功!</li>" & vbCrLf
strJS = strJS & " var url" & i & "='图片地址'+(parent.document.myform.PhotoUrl.length+1)+'|" & dirMonth & strFileName & "." & cFileExt & "'; " & vbCrLf
strJS = strJS & "parent.document.myform.PhotoUrl.options[parent.document.myform.PhotoUrl.length]=new Option(url" & i & ",url" & i & ");" & vbCrLf
If PhotoObject > 0 Then
If IsThumb = i Then
strThumbPath = SavePath & dirMonth & strFileName & "_S." & cFileExt
If PE_Thumb.CreateThumb(tmpPath, strThumbPath, Thumb_DefaultWidth, Thumb_DefaultHeight) = True Then
strJS = strJS & "parent.document.myform.PhotoThumb.value='" & dirMonth & strFileName & "_S." & cFileExt & "'; " & vbCrLf
Else
strJS = strJS & "parent.document.myform.PhotoThumb.value='" & dirMonth & strFileName & "." & cFileExt & "'; " & vbCrLf
End If
End If
Call PE_Thumb.AddWatermark(tmpPath)
Else
If IsThumb = i Then
strJS = strJS & "parent.document.myform.PhotoThumb.value='" & dirMonth & strFileName & "." & cFileExt & "'; " & vbCrLf
End If
End If
Case "softpic"
Response.Write "图片上传成功! <a href='javascript:history.go(-1)'>继续上传</a>"
strJS = strJS & "parent.document.myform.SoftPicUrl.value='UploadSoftPic/" & dirMonth & strFileName & "." & cFileExt & "';" & vbCrLf
If PhotoObject > 0 Then
If PE_Thumb.CreateThumb(tmpPath, tmpPath, 0, 0) = True Then
FileCount = FileCount + 1
End If
Call PE_Thumb.AddWatermark(tmpPath)
End If
Exit For
Case "soft"
Response.Write "文件上传成功! <a href='javascript:history.go(-1)'>继续上传</a>"
strJS = strJS & "var url='下载地址'+(parent.document.myform.DownloadUrl.length+1)+'|" & dirMonth & strFileName & "." & cFileExt & "'; " & vbCrLf
strJS = strJS & "parent.document.myform.DownloadUrl.options[parent.document.myform.DownloadUrl.length]=new Option(url,url);" & vbCrLf
strJS = strJS & "parent.document.myform.SoftSize.value='" & CStr(Round(cFileSize / 1024)) & "';" & vbCrLf
Exit For
Case "authorpic", "copyfrompic"
Response.Write "文件上传成功! <a href='javascript:history.go(-1)'>继续上传</a>"
strJS = strJS & "parent.document.myform.Photo.value='" & InstallDir & FileType & "/" & dirMonth & strFileName & "." & cFileExt & "';" & vbCrLf
strJS = strJS & "parent.document.myform.showphoto.src='" & InstallDir & FileType & "/" & dirMonth & strFileName & "." & cFileExt & "';" & vbCrLf
Exit For
Case "producerpic", "trademarkpic"
Response.Write "文件上传成功! <a href='javascript:history.go(-1)'>继续上传</a>"
strJS = strJS & "parent.document.myform.Photo.value='" & InstallDir & "Shop/" & FileType & "/" & dirMonth & strFileName & "." & cFileExt & "';" & vbCrLf
strJS = strJS & "parent.document.myform.showphoto.src='" & InstallDir & "Shop/" & FileType & "/" & dirMonth & strFileName & "." & cFileExt & "';" & vbCrLf
Exit For
Case "adminblogpic"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -