<!--#include file="Conn.asp" -->
<!--#include file="Inc/iXs_ClsUpLoad.asp" -->
<!--#include file="const.asp" -->
<%
'=========================================================
' 文件：iXs_UpLoadPost.asp
' 功能：爱雪儿通用上传管理类
' 版本：爱雪儿图文管理系统 PAMS Version 1.1.0
' 时间：2006-01-05
' 作者：Guidy
' 版权：爱雪儿工作室 [iXuEr Studio]
'=========================================================
' Copyright (C) 2005-2008 iXuEr.Net All Rights Reserved .
' 官方网站：http://www.ixuer.net/
' 技术论坛：http://bbs.ixuer.net/
' 电子信箱：guidy@114xp.cn
'=========================================================
On Error Resume Next
Response.ExpiresAbsolute = Now() - 1
Response.Expires = -1
Response.CacheControl = "no-cache"
Server.ScriptTimeout = 9999

Dim Temp, TempHtml, Templates
Dim Action, HaveErr
Dim ObjUpType, ObjUpClass, bgColor, Wid
Dim n, Self_Referer
Dim UpLoadPID, CreatPreview

Action = iXs.ReqNum("Action", 0)
bgColor = iXs.ReqStr("bgColor", "")
Wid = iXs.ReqNum("Wid", 0)
Self_Referer = Request.ServerVariables("HTTP_REFERER")
CreatPreview = True
' ----------------------------------------------------------------------------------------
' 上传参数设置
Dim FileSavePath, FileUpMaxNum, FileAllowExt, FileMaxSize, FilePrevPath

iXs.UpFileObject 	= 0 ' UpFileObject = 1 ' 设置上传组件类型（0=无组件上传类，1=AspUpLoad3.0 ,2=SA-FileUp 4.0 ,3=DvFile.UpLoad V1.0
FileSavePath 		= SavePath & "Upload" ' 保存路径
FileUpMaxNum 		= 1 ' 一次上传最大个数
FileAllowExt 		= "avi|asf|wmv|rm|rmvb|mpg|mpeg|flv|3gp|mov" ' 文件类型
FileMaxSize  		= 409600 ' 文件大小限制
FilePrevPath 		= "PreviewImage/" ' 预览图保存路径
' ----------------------------------------------------------------------------------------
%>
<style type="text/css">
	body,td,th {color: #000000;font: 12px Tahoma, "宋体";}
	body{margin:0px; background-color:{$UpLoadBackGroundColor};}
	form{margin:0px;}
	input{Border: 1px solid #000000;BackGround-Color: buttonface;Color: #000000;height:17px;font: 12px Tahoma, "宋体";}
	.red{color:#FF0000;}
</style>
<script type="text/javascript">
<!--
	if(top.location == self.location){
		alert("请不要非法调用此文件！");
		top.location="Index.asp";
	}
-->
</script>
</head>
<body>
<%
' ----------------------------------------------------------------------------------------
Select Case Action
	Case 1
		Dim UpLoad, UpForm
		Dim FileID, FormName, FileName, FilePath, PreviewPath
		
		Set UpLoad = New iXuEr_UpFile
		Set UpForm = New FileInfo_Cls
		
		' 上传进度数据文件名 为了适应多用户 多进程相互独立显示而增加
		UpLoadPID = iXs.ReqStr("UpLoadPID", 0)
		UpLoad.AutoDir = 0 ' 文件目录创建方式：0=年月目录，1=年月日
		
		PreviewPath	= UpLoad.CreatePath(FilePrevPath)
		'FilePath 	= UpLoad.CreatePath(FileSavePath)
		FilePath 	= FileSavePath
		
		UpLoad.UpLoadPID			= UpLoadPID							' 上传ID
		UpLoad.UpLoadPath			= FilePath							' 设置上传路径
		'UpLoad.ChkSessionName		= "UpLoad_Form"						' 防止重复提交，SESSION名与提交的表单要一致。
		UpLoad.UpLoadType			= iXs.UpFileObject					' 设置上传组件类型（0=无组件上传类，1=AspUpLoad3.0 ,2=SA-FileUp 4.0 ,3=DvFile.UpLoad V1.0）
		UpLoad.InceptMaxFile		= FileUpMaxNum						' 每次上传文件个数上限
		UpLoad.InceptFileType		= Replace(FileAllowExt, "|", ",")	' 设置上传文件限制 多个用“,”隔开
		UpLoad.MaxSize				= FileMaxSize						' 单位 KB
		UpLoad.FormatType			= 0									' 定义文件命名方法（0 = 自动生成14位时间＋5位随机数命名，1 = 使用文件原名称命名）
		UpLoad.RName				= ""							' 定义文件名前缀
		UpLoad.FileExt_1			= "jpg|jpeg|gif|bmp|png|tif|iff"
																		' 设置图像类文件类型
		UpLoad.FileExt_2			= "swf|swi"							' 设置动画文件类型
		UpLoad.FileExt_3			= "mp3|m3u|wav|wma|wax|asx|asf|mp2|au|aif|aiff|mid|midi|rmi"
																		' 设置音频文件类型 全部采用Windows Media Player播放
		UpLoad.FileExt_4			= "rm|rmvb|ram|ra|mov"				' 设置RealPlayer 文件类型
		UpLoad.FileExt_5			= "dat|mpg|mpeg|mpv|mps|m2v|m1v|mpe|mpa|avi|wmv|wm|wmx|wvx"
																		' 设置Windows Media 视频文件类型
		UpLoad.FileExt_6			= "asa|asp|bat|cmd|code|com|dat|db|dll|doc|exe|fla|ftp|h|hlp|htm|html|inc|info|ini|js|log|mdb|pdf|php|pic|ppt|rar|real|torrent|txt|xls|xml|zip"
																		' 设置其他文件类型
		'预览图片设置
		UpLoad.PreviewType			= 1									' 设置预览图片组件类型(0=CreatePreviewImage组件，1=AspJpegV1.2 ,2=SoftArtisans ImgWriter V1.21)
		UpLoad.PreviewImageWidth	= 180								' 设置预览图片宽度
		UpLoad.PreviewImageHeight	= 150								' 设置预览图片高度
		UpLoad.DrawImageWidth		= 180								' 设置水印图片或文字区域宽度
		UpLoad.DrawImageHeight		= 60								' 设置水印图片或文字区域高度
		UpLoad.DrawGraph			= 1									' 设置水印透明度
		UpLoad.DrawFontColor		= "#FF0000"							' 设置水印文字颜色
		UpLoad.DrawFontFamily		= "Arial"							' 设置水印文字字体格式
		UpLoad.DrawFontSize			= 12								' 设置水印文字字体大小
		UpLoad.DrawFontBold			= True								' 设置水印文字是否粗体
		UpLoad.DrawInfo				= "Images/WaterMap_4.gif"			' 设置水印文字信息或图片信息
		UpLoad.DrawType				= 2									' 0=不加载水印 ，1=加载水印文字，2=加载水印图片
		UpLoad.DrawXYType			= 4									' "0"=左上，"1"=左下,"2"=居中,"3"=右上,"4"=右下
		UpLoad.DrawSizeType			= 1									' "0"=固定缩小，"1"=等比例缩小
		UpLoad.TransitionColor		= "#F0F0F0"							' 透明度颜色设置 水印图片去除底色
		' 执行上传
		UpLoad.SaveUpFile

		Dim File, F_FileName, F_Viewname
		Dim iFileName, iFileSize
		If UpLoad.Count > 0 Then
			For Each FormName In UpLoad.UpLoadFiles
				Set File = UpLoad.UpLoadFiles(FormName)

				iFileName = File.FileName
				iFileSize = File.FileSize

				Set File = Nothing
			Next

			'Templates = "文件名：" & iFileName & " &nbsp; 扩展名：" & iFileExt & " &nbsp; 文件大小：" & iFileSize
			Response.Write("<form method=""post"" action=""../cm-mov_video.asp"" target=""_top""><input type=""hidden"" name=""FileName"" value=""" & iFileName & """><input type=""hidden"" name=""FileSize"" value=""" & iFileSize & """></form><script>document.forms[0].submit();</script>")

		Else
			Response.Write("请正确选择要上传的文件。[<a href=""" & Self_Referer & """>重新上传</a>]")
		End If
		Set UpForm = Nothing
		Set UpLoad = Nothing
	Case Else ' 显示上传接口
		' 根据组件类型生成上传ID
		Dim OpenUpLoadProgress
		OpenUpLoadProgress = "false"
		If iXs.UpFileObject = 0 Then
			Randomize Timer()
			UpLoadPID = FormatTime(Now(), 1) & Clng(1000 + Rnd()*8999)
			OpenUpLoadProgress = "true"
		ElseIf iXs.UpFileObject = 1 Then
			' 生成 AspUpLoad 进度ID
			Dim UpLoadProgress
			Set UpLoadProgress = Server.CreateObject(ServerObject_012)
			UpLoadPID = UpLoadProgress.CreateProgressID()
			Set UpLoadProgress = Nothing
			OpenUpLoadProgress = "true"
			If Err Then
				Err.Clear
				OpenUpLoadProgress = "false"
			End If
		End If
		' 输出界面
' ----------------------------------------------------------------------------------------
%><!--上传接口-->
<form action="iXs_UpLoadPost.asp?bgColor=<% = bgColor %>&amp;Action=1&amp;Wid=<% = Wid %>&amp;UpLoadPID=<% = UpLoadPID %>" method="post" enctype="multipart/form-data" id="UpLoad_Form" onsubmit="return apply()">
	<input name="upcount" type="hidden" id="upcount" value="1" size="4" maxlength="3" />
	<input type="hidden" id="setids" name="setids" value=" 设 定 " />
	<input name="Files" type="hidden" id="Files" value="" />
	请选择文件：<input name="strFile1" type="file" id="strFile1" style="width:200px;" onchange="return CheckUploadForm();" />
	<input type="submit" id="submit" name="submit" value=" 上 传 " onclick="return CheckUploadForm();" />
</form>
<script type="text/javascript">
<!--
	var iframeids = ["UpLoad_Ad"];
	var iframehide = "yes";
	var sAllowExt = "<% = FileAllowExt %>";
	var OpenUpLoadProgress = <% = OpenUpLoadProgress %>; // 是否开启上传进度条
	var i = 0;
	var n = 0;
	var Obj01 = window.UpLoad_Form.upcount;
	var Obj02 = document.getElementById("Files");
	
	function setid(){
		str='';
		var MaxNum = <% = FileUpMaxNum %>;
		if(!Obj01.value){Obj01.value = 1;}
		if(Obj01.value == 0){Obj01.value = 1;}
		if(Obj01.value > MaxNum){
			alert("您最多只能同时上传 " + MaxNum + " 个文件!");
			Obj01.value = MaxNum;
			setid();
		}
		else{
			for(n=1;n<=Obj01.value;n++){
				str += '文件';
				if(n < 10)(str += 0)
				str += n+'：<input type="file" name="strFile' + n + '" id="strFile' + n + '" style="width:200px;" onChange="return CheckUploadForm();" /><br>';
				window.upid.innerHTML = str;
			}
			dyniframesize();
		}
	}
	function apply(){
		try{
			// 检测并禁用文件域表单
			for(n = 1;n <= Obj01.value;n ++){
				document.getElementById("strFile" + n).readOnly = true;
			}
			// 禁用提交表单
			document.getElementById("submit").disabled = true;
			// 禁用数目设置和按钮
			document.getElementById("upcount").disabled = true;
			document.getElementById("setids").disabled = true;
			// 打开进度条对话框
			if(OpenUpLoadProgress==true){
				return WinPop("iXs_UpLoadProgress.asp?UpLoadPID=<% = UpLoadPID %>&Files=" + Obj02.value, 430, 165);
			}
		}
		catch(e){};
	}
	// 生成弹出窗口
	function WinPop(url, width, height){
		window.showModelessDialog(url, "UpLoadProgress",'dialogWidth=' + width + 'px; dialogHeight=' + height + 'px; resizable=no; help=no; scroll=no; status=no;') 
	}
	// 是否有效的扩展名
	function IsExt(url, opt){
		var sTemp;
		var b=false;
		var s=opt.toUpperCase().split("|");
		for (var i=0;i<s.length ;i++ ){
			sTemp=url.substr(url.length-s[i].length-1);
			sTemp=sTemp.toUpperCase();
			s[i]="."+s[i];
			if (s[i]==sTemp){
				b=true;
				break;
			}
		}
		return b;
	}
	// 检测上传表单 检测扩展名是否有效
	function CheckUploadForm() {
		var Obj;
		var tempstr;
		Obj02.value = ""
		for(n=1;n<=Obj01.value;n++){
			Obj = document.getElementById("strFile" + n);
			if(!IsExt(Obj.value, sAllowExt) && Obj.value!=""){
				alert("提示：\n\n第 【" + n + "】 个文件无效！\n\n请选择一个有效的文件，\n支持的格式有：\n" + sAllowExt);
				Obj.style.border = "2px solid #FF0000";
				return false;
			}
			tempstr = Obj.value.replace(/.+?\\/gi, "");
			if(Obj02.value==""){
				Obj02.value = tempstr;
			}else{
				Obj02.value += "|" + tempstr;
			}
			Obj.style.border = "1px solid #000000";
		}
		return true
	}
//-->
</script><%
' ----------------------------------------------------------------------------------------
End Select
%>
</body>
</html>