<%
Sub UploadFile ()
Dim Upload, FilePath, sFilePath, FormName, File, F_FileName
Dim PreviewSetting, DrawInfo, Previewpath, strPreviewPath
Dim PreviewName, F_Viewname, MakePreview
'-- Whether to generate a thumbnail
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) 'directory generated by date
FilePath = sUploadDir & sFilePath
Set Upload = New UpFile_Cls
Upload. UploadType = UploadObject 'sets the Upload component type.
Upload. UploadPath = FilePath 'sets the Upload path
Upload. MaxSize = AllowFileSize 'unit: KB
Upload. InceptMaxFile = 10' maximum number of files uploaded each time
Upload. InceptFileType = AllowFileExt'
'Upload. ChkSessionName = "uploadfile"
'Preview image settings
Upload. MakePreview = MakePreview
Upload. PreviewType = CInt (PreviewSetting (0) 'sets the preview image component type
Upload. PreviewImageWidth = CInt (PreviewSetting (3) 'sets the preview image width.
Upload. PreviewImageHeight = CInt (PreviewSetting (4) 'sets the preview image height
Upload. DrawImageWidth = CInt (PreviewSetting (13) 'sets the width of the watermark image or text area.
Upload. DrawImageHeight = CInt (PreviewSetting (14) 'sets the height of the watermark image or text area.
Upload. DrawGraph = CCur (PreviewSetting (11) 'sets the watermark transparency
Upload. DrawFontColor = PreviewSetting (7) 'sets the watermark text color
Upload. DrawFontFamily = PreviewSetting (8) 'sets the watermark text font format
Upload. DrawFontSize = CInt (PreviewSetting (6) 'sets the watermark text font size
Upload. DrawFontBold = CInt (PreviewSetting (9) 'sets whether the watermark text is in bold.
Upload. DrawInfo = DrawInfo 'sets the watermark text or image information.
Upload. DrawType = CInt (PreviewSetting (2) '0 = do not load watermark, 1 = load watermark text, 2 = load watermark image
Upload. drawXYType = CInt (PreviewSetting (15) '"0" = upper left, "1" = lower left, "2" = center, "3" = upper right, "4" = lower right
Upload. DrawSizeType = CInt (PreviewSetting (1) '"0" = fixed reduction, "1" = proportional reduction
If PreviewSetting (12) <> "" Or PreviewSetting (12) <> "0" Then
Upload. TransitionColor = PreviewSetting (12) 'transparency color settings
End If
'Upload execution
Upload. SaveUpFile
If Upload. ErrCodes <> 0 Then
Response. write ("<script> alert ('Error:" & 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
'Create a preview and a watermark image
If Upload. PreviewType <> 999 and File. FileType = 1 then
PreviewName = "p" & Replace (File. FileName, File. FileExt, "") & "jpg"
F_Viewname = Previewpath & PreviewName
'Create a preview image: Call CreateView (original file path, Preview file name and path, original file suffix)
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 ("^_^ buddy! Select a valid file to upload. ")
Exit Sub
End If
Set Upload = Nothing
End Sub
Sub OutScript (url)
Response. Write "<script language = javascript>" & vbCrLf
Response. Write "parent.doc ument. myform. filePath. value = '" & url & "';" & vbCrLf
Response. Write "alert ('file uploaded successfully! \ 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.doc ument. myform. ImageUrl. value = '" & url & "';" & vbCrLf
Response. Write "</script>" & vbCrLf
End Sub
%>