一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp文件上传代码

时间:2022-07-02 23:17:47 编辑:袖梨 来源:一聚教程网

<%
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 ("")
  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 "" & vbCrLf
End Sub

Sub OutPreview(url)
 Response.Write "" & vbCrLf
End Sub
%>

热门栏目