<%
Sub UploadFile()
Dim Upload,FilePath,sFilePath,FormName,File,F_FileName
Dim PreviewSetting,DrawInfo,Previewpath,strPreviewPath
Dim PreviewName,F_Viewname,MakePreview
'-- 是否產生縮圖片
MakePreview = True
Previewpath = Newasp.InstallDir & Newasp.ChannelDir
strPreviewPath = "UploadPic/" & CreatePath(Previewpath & "UploadPic/")
PreviewPath = Previewpath & strPreviewpath
PreviewSetting = Split(Newasp.PreviewSetting, ",")
If CInt(PreviewSetting(2)) = 1 Then
DrawInfo = PreviewSetting(5)
ElseIf CInt(PreviewSetting(2)) = 2 Then
DrawInfo = Newasp.InstallDir & PreviewSetting(10)
Else
DrawInfo = ""
End If
If DrawInfo = "0" Then
DrawInfo = ""
PreviewSetting(2) = 0
End If
sFilePath = CreatePath(sUploadDir) '按日期組建目錄
FilePath = sUploadDir & sFilePath
Set Upload = New UpFile_Cls
Upload.UploadType = UploadObject '設定上傳組件類型
Upload.UploadPath = FilePath '設定上傳路徑
Upload.MaxSize = AllowFileSize '單位 KB
Upload.InceptMaxFile = 10 '每次上傳檔案個數上限
Upload.InceptFileType = AllowFileExt '設定上傳檔案限制
'Upload.ChkSessionName = "uploadfile"
'預覽圖片設定
Upload.MakePreview = MakePreview
Upload.PreviewType = CInt(PreviewSetting(0)) '設定預覽圖片組件類型
Upload.PreviewImageWidth = CInt(PreviewSetting(3)) '設定預覽圖片寬度
Upload.PreviewImageHeight = CInt(PreviewSetting(4)) '設定預覽圖片高度
Upload.DrawImageWidth = CInt(PreviewSetting(13)) '設定浮水印圖片或文字地區寬度
Upload.DrawImageHeight = CInt(PreviewSetting(14)) '設定浮水印圖片或文字地區高度
Upload.DrawGraph = CCur(PreviewSetting(11)) '設定浮水印透明度
Upload.DrawFontColor = PreviewSetting(7) '設定浮水印文字顏色
Upload.DrawFontFamily = PreviewSetting(8) '設定浮水印文字字型格式
Upload.DrawFontSize = CInt(PreviewSetting(6)) '設定浮水印文字字型大小
Upload.DrawFontBold = CInt(PreviewSetting(9)) '設定浮水印文字是否粗體
Upload.DrawInfo = DrawInfo '設定浮水印文字資訊或圖片資訊
Upload.DrawType = CInt(PreviewSetting(2)) '0=不載入浮水印 ,1=載入浮水印文字,2=載入浮水印圖片
Upload.DrawXYType = CInt(PreviewSetting(15)) '"0" =左上,"1"=左下,"2"=置中,"3"=右上,"4"=右下
Upload.DrawSizeType = CInt(PreviewSetting(1)) '"0"=固定縮小,"1"=等比例縮小
If PreviewSetting(12)<>"" Or PreviewSetting(12)<>"0" Then
Upload.TransitionColor = PreviewSetting(12) '透明度顏色設定
End If
'執行上傳
Upload.SaveUpFile
If Upload.ErrCodes<>0 Then
Response.write ("<script>alert('錯誤:"& Upload.Description & "');history.go(-1)</script>")
Exit Sub
End If
If Upload.Count > 0 Then
For Each FormName In Upload.UploadFiles
Set File = Upload.UploadFiles(FormName)
F_FileName = FilePath & File.FileName
SaveFileName = F_FileName
'建立預覽及浮水印圖片
If Upload.PreviewType<>999 and File.FileType=1 then
PreviewName = "p" & Replace(File.FileName,File.FileExt,"") & "jpg"
F_Viewname = Previewpath & PreviewName
'建立預覽圖片:Call CreateView(原始檔案的路徑,預覽檔案名稱及路徑,原檔案尾碼)
Upload.CreateView F_FileName,F_Viewname,File.FileExt
If CBool(MakePreview) Then
Call OutPreview(strPreviewPath & PreviewName)
End If
End If
Set File = Nothing
Next
Else
Call OutAlertScript("^_^哥們!請選擇一個有效上傳檔案。")
Exit Sub
End If
Set Upload = Nothing
End Sub
Sub OutScript(url)
Response.Write "<script language=javascript>" & vbCrLf
Response.Write "parent.document.myform.filePath.value='" & url & "';" & vbCrLf
Response.Write "alert('檔案上傳成功!\n"&url&"');" & vbCrLf
Response.Write "history.go(-1);" & vbCrLf
'Response.Write "location.replace('" & Request.ServerVariables("HTTP_REFERER") & "')" & vbCrLf
Response.Write "</script>" & vbCrLf
End Sub
Sub OutPreview(url)
Response.Write "<script language=javascript>" & vbCrLf
Response.Write "parent.document.myform.ImageUrl.value='" & url & "';" & vbCrLf
Response.Write "</script>" & vbCrLf
End Sub
%>