<?php if(!defined('APP_PATH')||!defined('I_PATH')){exit('Access Denied');} ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="admin/admin/template/style/admin.css" rel="stylesheet" type="text/css" />
<script src="include/js/jquery.js" type="text/javascript"></script>
<script src="include/js/uploadify/swfobject.js" type="text/javascript"></script>
<script src="include/js/uploadify/uploadify.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	$("#files").uploadify({
		'script'         : 'admin.php',
		'scriptData'	 : {'c':'uploads','isfiles':'Filedata','session_id':'<?php echo session_id();?>'},
		'queueID'        : 'fileQueue',
		'auto'           : true,	//自动上传
		'multi'          : <?php echo $multi ?>,	//是否可以传多个文件
		'removeCompleted': true,	//完成移除进度条
		'fileDesc' 		 : '选择文件',
		'fileExt'		 : '<?php echo $fileExt ?>',		//格式限制
		'sizeLimit'		 : <?php echo $sizeLimit ?>,	//大小限制
		"onError": function (event,queueId,fileObj,errorObj){
				$("#err").empty();$("#fileQueue").empty();
				if(errorObj.type=="File Size"){
					var fSizes = errorObj.info/1024;
					alert("文件大小不能超过"+fSizes+"K");
				}else{
					alert("上传出错，请重新操作");
				}
		},
		'onOpen': function (){
				<?php if($fileover==1){ ?>
				$("#err").empty();
				$("#err").append("<img src='include/js/uploadify/loading.gif' />");
				<?php }else{ ?>
				$("#filesinput").empty();
				$("#filesinput").append("<img src='include/js/uploadify/loading.gif' /> 上传中，结束后将自动插入文件.....");
				<?php } ?>
		},
<?php if($fileover==1){ ?>
		'onComplete': function (event, queueID, fileObj, response, data){
				var strs=response.split(",");
				var tt=response.substring(0,3);
				$("#err").empty();
				if(tt.indexOf('0,')==-1){
					$("#fileQueue").empty();
					$("#err").append(strs[0]);
				}else{
					<?php if($multi=='false'){ ?>
					$(window.parent.document).find("#<?php echo $inputid ?>").attr("value",strs[1]);
					$(window.parent.document).find("#<?php echo $inputid ?>over dd").remove();
					$(window.parent.document).find("#<?php echo $inputid ?>over").css("display","block");
					$(window.parent.document).find("#<?php echo $inputid ?>over").append("<dd><img src='"+strs[1]+"' height='50' /></dd>");
					<?php }else{ ?>
					$(window.parent.document).find("#<?php echo $inputid ?>over").css("display","block");
					if(strs[3]==1){
					$(window.parent.document).find("#<?php echo $inputid ?>over").append('<dd id="f_'+strs[2]+'"><img src="'+strs[1]+'" height="50" width="60" /><input name="<?php echo $inputid ?>file[]" type="hidden" value="'+strs[1]+'" /><br /><input name="<?php echo $inputid ?>txt[]" type="text" class="int" style="width:52px;height:12px;" /><br /><a onclick=delfieldall("f_'+strs[2]+'") style="width:43;padding-left:17px;cursor:pointer;">删除</a></dd>');
					}else{
					$(window.parent.document).find("#<?php echo $inputid ?>over").append('<dd id="f_'+strs[2]+'"><a href="'+strs[1]+'" target="_blank" class="f">'+strs[3]+'文件</a><br /><input name="<?php echo $inputid ?>file[]" type="hidden" value="'strs[1]+'" /><br /><input name="<?php echo $inputid ?>txt[]" type="text" class="int" style="width:52px;height:12px;" /><br /><a onclick=delfieldall("f_'+strs[2]+'") style="width:43;padding-left:17px;cursor:pointer;">删除</a></dd>');
					}
					<?php } ?>
				}
		}
<?php }else if($fileover==2){ ?>
		<?php if($multi=='true'){ ?>
		'onComplete': function (event, queueID, fileObj, response, data){
				var strs=response.split(",");
				var tta=response.substring(0,3);
				$("#filesinput").empty();
				if(tta.indexOf('0,')==-1){
					alert(strs[0]);
				}else{
					$("#onAll").append(strs[1]+" ");
				}
		},
		'onAllComplete': function (event, data){
			if($("#onAll").text().length){
				callback("!"+$("#onAll").text());
				$("#onAll").empty();
			}
		}
		<?php }else{ ?>
		'onComplete': function (event, queueID, fileObj, response, data){
				var strs=response.split(",");
				var ttb=response.substring(0,3);
				$("#filesinput").empty();
				if(ttb.indexOf('0,')==-1){
					alert(strs[0]);
				}else{
					callback(strs[1]);
				}
		}
		<?php } ?>
<?php } ?>
	});
});
</script>
</head>
<body>
<?php if($fileover==2){ ?>
<style type="text/css">
.uploadifyQueueItem {
	border-bottom: 1px solid #E5E5E5;
	font: 11px Verdana, Geneva, sans-serif;
	padding: 10px;
	width: auto;
}
.uploadifyError {
	background-color: #FDE5DD !important;
	border: 2px solid #FBCBBC !important;
}
.uploadifyQueueItem .cancel {
	float: right;padding:0;
}
.uploadifyQueue .completed {
	background-color: #F6F6F6;
}
.uploadifyProgress {
	background-color: #F6F6F6;
	margin-top: 10px;
	width: 100%;
}
.uploadifyProgressBar {
	background-color: #0099FF;
	height: 3px;
	width: 1px;
}
</style>
<div style="width:auto; height:197px;overflow-x:hidden;overflow-y:auto;">
<table width="100%" style="border-bottom:1px solid #CCC;background:url(admin/admin/template/images/lin.gif);">
<tr><td style="color: #476DD1;"><input name="files" id="files" type="file" /></td>
<td align="right"><div id="filesinput">
<?php if($multi=='true'){ ?>
可一次选择多个文件同时上传&nbsp;
<?php } ?></div>
</td></tr>
</table>
<div id="fileQueue" style="float:left; width:100%;"></div>
</div>
<?php }else{ ?>
<style type="text/css">
.uploadifyQueueItem {width: 150px; font-size:10px; font-family:Verdana, Geneva, sans-serif; line-height:13px;}
.uploadifyError {background-color: #FDE5DD !important;}
.uploadifyQueueItem .cancel {float: right; padding-top:6px;}
.uploadifyQueue .completed {}
.uploadifyProgress {margin-top: 10px;width: 100%;}
.uploadifyProgressBar {background-color: #0099FF;height: 3px;width: 1px;}
</style>
<div style="float:left; height:26px; width:90px; "><input name="files" id="files" type="file" /></div><div id="err" style="float:left; line-height:26px; margin-right:3px;"></div><div id="fileQueue" style="float:left;"></div>
<?php } ?>
<div id="onAll" style="display:none;"></div>
</body>
</html>
