⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user_upload.asp

📁 依蓝旅游网站管理系统Elan2008.SP2
💻 ASP
字号:
<%
Option Explicit
Response.Buffer = True
Server.ScriptTimeOut = 9999999
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1 
Response.CacheControl = "no-cache"
%>
<!--#Include File="../Conn.asp"-->
<!--#include file="../Inc/Const.asp" -->
<!--#Include File="User_CheckPurview.asp"-->
<!--#include file="../Inc/ClassUpload.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文件上传</title>
<script language="javascript" src="../js/Common.js"></script>
<style>
body{ 
   color:#444444; 
   font-size: 12px;
   margin-top: 0px;
   margin-right: 0px;
   margin-bottom: 0px;
   margin-left: 0px; 
   padding:0px;
   background-color:transparent;
}

td{  
   font-size:12px; 
   word-break:break all; 
   word-wrap:word-break;
   line-height: 150%; 
}

form{ 
   margin:0px;
   padding:0px;
}
input{ 
   height:20;
   font-size: 12px ;
   margin-left:5px;
}
div{
   font-size:9px; color:#FFFFFF; font-family:Arial, Helvetica, sans-serif;
}
.bar{
   width:335px; border:1px solid blue; margin-top:5px;margin-left:5px;margin-bottom:2px; height:10px;
}
</style>
</head>
<body oncontextmenu="return ;">
<% If Action="Save" Then %>
<!--暂时解决由于页面处理大数据的延迟、小数据过快导致进度条不能实时反映状态的问题-->
<div id="progressbar" class="bar">
  <div style="width:100%; background: blue; text-indent:10px;">Completed ! Please wait for data processing ......</div>
</div>
<% 
Else 
%>
<div id="progressbar" class="bar">
  <div style="width:100%; background: #FFFFFF; color:blue; text-indent:10px;">Ready....</div>
</div>
<% End If %>
<script language="javascript" src="../js/UploadProgress.js"></script>
<%
Function ObjectTest(strObj)
	On Error Resume Next	
	Dim TestObj, IsObj
	IsObj = False
	Set TestObj = Server.CreateObject(strObj)
	If -2147221005 <> Err then
		IsObj = True
	Else
	   IsObj = False
	   Err.Clear
	End If
	Set TestObj = Nothing
	ObjectTest = IsObj
End Function

Function EL_CreateFolder(StrPath, NewFolder)
   On Error Resume Next
   Dim FSO
   EL_CreateFolder = StrPath
   If ObjectTest(Object_FSO) = False Then Exit Function
   Set FSO = Server.CreateObject(Object_FSO)   
   IF NOT FSO.FolderExists(StrPath & NewFolder) Then
      FSO.CreateFolder(StrPath & NewFolder)
   End If
   Set FSO = Nothing
   If Err Then
      Err.Clear
   Else
      EL_CreateFolder = StrPath & NewFolder
   End If
End Function

Dim DialogType, EventName, IsCreatedThumb, Opt

DialogType = Request("DialogType")
EventName = Request("EventName")
IsCreatedThumb = Request("IsCreatedThumb")
Opt = Request("Opt")



If IsCreatedThumb = "" Then IsCreatedThumb = "0"

Select Case Action
   Case "Save": Call SaveFile()
   Case "": Call Main()
End Select

Call ApplicationTerminate()

Sub SaveFile()
   Response.Flush()
   Dim File_Ext, SavePath, Upload, FileName, arrUploadExt, SubFolder, ThumbFileName, JpegErrorCode
   Dim sChannelDir, sUploadDir, sUploadMaxSize, sUploadFileType
   JpegErrorCode = 0
   
   If Opt = "face" Then
      sChannelDir = "Userface"
      sUploadDir = "Uploadfiles"
      sUploadMaxSize = EL_Common.GetFieldValue("UploadUserfaceMaxSize", "EL_Config", "1=1")
      sUploadFileType = "jpg|bmp|gif|png$swf$mid|mp3|wmv|asf|avi|mpg$ram|rm|ra$rar|exe|doc|zip"
	  If sUploadMaxSize<=0 Then sUploadMaxSize = 50
   Else
      Response.Write "<scr" & "ipt>alert('页面参数错误');window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt=face&IsCreatedThumb="& IsCreatedThumb &"';</scr" & "ipt>"
   End If
   
   SavePath = Server.MapPath(InstallDir & sChannelDir &"/"& sUploadDir)   
   SubFolder = Year(date()) & Right("0"& Month(date()), 2)
   SavePath = EL_CreateFolder(SavePath, "\"& SubFolder) 
   

   If sUploadFileType = "" Then sUploadFileType = "$$$$"
   arrUploadExt = Split(sUploadFileType,"$")
   
   Select Case DialogType
     Case "pic":    File_Ext = arrUploadExt(0)
	 Case "flash":  File_Ext = arrUploadExt(1)
	 Case "media":  File_Ext = arrUploadExt(2)
	 Case "real":   File_Ext = arrUploadExt(3)
	 Case "fujian": File_Ext = arrUploadExt(4)
   End Select
   
   Set Upload = New ClassUpload
   Upload.SetUploadMaxSize = EL_Common.ELClng(sUploadMaxSize) * 1000
   Upload.SetAllowFileExt = File_Ext
   Upload.SetSaveFilePath = SavePath
   Upload.SetChunkBytes = 1024 * 30
   Upload.Upload("filedata")
   If Upload.ErrorCode > 0 Then '上传过程有错误
     Select Case Upload.ErrorCode
	    Case 1: Response.Write "<scr" & "ipt>alert('没有数据上传');window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';</scr" & "ipt>"
		Case 2: Response.Write "<scr" & "ipt>alert('上传文件大小超过限制 "& sUploadMaxSize &" K');window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';</scr" & "ipt>"
		Case 3: Response.Write "<scr" & "ipt>alert('上传文件类型( "& Upload.GetFileExt() &" : "& File_Ext &" )错误');window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';</scr" & "ipt>"
		Case 4: Response.Write "<scr" & "ipt>alert('上传路径错误,目标路径不存在');window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';</scr" & "ipt>"
		Case 5: Response.Write "<scr" & "ipt>alert('该图片内容包含恶意木马信息');window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';</scr" & "ipt>"
	 End Select
   End If
   FileName = SubFolder &"/"& Upload.GetFileName()
   Set Upload = Nothing   
   
   
   If DialogType = "pic" And Opt <> "face" Then
      '----------添加水印---------------
	  Dim TempFlag, FileTruePath
	  FileTruePath = Server.MapPath(InstallDir & sChannelDir &"/"& sUploadDir &"/"& FileName)
	  TempFlag = False
      If EnableWatermark = True Then
         Dim JpegWatermark
	     Set JpegWatermark = New ClassJpeg
		 If JpegWatermark.ErrorCode = 0 Then
	        JpegWatermark.CreateWatermark FileTruePath 
	        If EnableCreateThumb = True And IsCreatedThumb = "1" Then
	           JpegWatermark.CreateThumb FileTruePath, 1 
			   ThumbFileName = SubFolder &"/"& JpegWatermark.ThumbFileName
			   JpegErrorCode = JpegWatermark.ErrorCode
		       TempFlag = True
	        End If
		 End If
	     Set JpegWatermark = Nothing
      End If
   
      '----------产生缩略图-------------
      If EnableCreateThumb = True And TempFlag = False And IsCreatedThumb = "1" And Opt <> "face" Then
         Dim JpegThumb
	     Set JpegThumb = New ClassJpeg
	     JpegThumb.CreateThumb FileTruePath, 1 
		 ThumbFileName = SubFolder &"/"& JpegThumb.ThumbFileName
		 JpegErrorCode = JpegThumb.ErrorCode
	     Set JpegThumb = Nothing
      End If
   End If
   
   Select Case DialogType
     Case "pic":    
	      Response.Write "<scr" & "ipt>"
		  If EnableCreateThumb = True And IsCreatedThumb = "1" And JpegErrorCode = 0 And Opt <> "face" Then 
		     Response.Write "parent."& EventName &"('"& FileName &"$$$"& ThumbFileName &"');"
		  Else
		     Response.Write "parent."& EventName &"('"& FileName &"');"
		  End If		  
		  Response.Write "window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';"
		  Response.Write "</scr" & "ipt>"    
	 Case "flash":  
	      Response.Write "<scr" & "ipt>"
		  Response.Write "parent."& EventName &"('"& FileName &"');"
		  Response.Write "window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';"
		  Response.Write "</scr" & "ipt>"    
	 Case "media":  
	      Response.Write "<scr" & "ipt>"
		  Response.Write "parent."& EventName &"('"& FileName &"');"
		  Response.Write "window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';"
		  Response.Write "</scr" & "ipt>"    
	 Case "real":     
	      Response.Write "<scr" & "ipt>"
		  Response.Write "parent."& EventName &"('"& FileName &"');"
		  Response.Write "window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';"
		  Response.Write "</scr" & "ipt>"    
	 Case "fujian": 
	      Response.Write "<scr" & "ipt>"
		  Response.Write "parent."& EventName &"('"& FileName &"');"
		  Response.Write "window.location.href='User_Upload.asp?DialogType="& DialogType &"&EventName="& EventName &"&Opt="& Opt &"&IsCreatedThumb="& IsCreatedThumb &"';"
		  Response.Write "</scr" & "ipt>"     
   End Select
   Response.Write "<script>progressbar.innerHTML=""<div style='width:100%; background: blue; text-indent:10px;'>Completed ! Please wait for data processing ......</div>""</script>"
End Sub
  
Sub Main()
%>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <form name="Upload" action="User_Upload.asp?Action=Save&DialogType=<%=DialogType%>&EventName=<%=EventName%>&Opt=<%=Opt%>&IsCreatedThumb=<%=IsCreatedThumb%>" method="post" enctype="multipart/form-data" onSubmit="SubmitOnce(this)">
  <tr>
    <td width="24%"><input name="filedata" type="file" id="filedata" size="34"></td>
    <td width="76%"><input name="Submit" type="submit" value=" 上传 " onClick="gop();" style="margin:0px; margin-left:3px; width:51px;"></td>
  </tr>
  </form>
</table>
<%
End Sub
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -