<?php
defined('ROOT_PHPLEFT') or exit('phpleft: Not page');
error_reporting(0);
/*
	phpleftDms Copyright (c) 2011 phpleft.COM
	商业授权：QQ45150208
	
*/
function createFolder($path)
 {
  if (!file_exists($path))
  {
   createFolder(dirname($path));
   mkdir($path, 0777);
  }
 }
createFolder("../upload/".date('Y',time())."/".date('m',time())."/".date('d',time())."/");
?>
<!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">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script src="<?=PL_URL?>js/win/artDialog.source.js?skin=default"></script>
<script src="<?=PL_URL?>js/win/plugins/iframeTools.source.js"></script>
</head>
<body style="font-size:12px;">
<?php if(!isset($_REQUEST['scan'])){?>
<div align="center" style="margin-top:20px;">
<form action="" method="post" enctype="multipart/form-data" name="form1">
<input type="file" name="file">
<input type="submit" name="Submit" value="提交">
<input name="scan" type="hidden" id="up" value="true">
</form></div>
<? }?>
<?php
if(isset($_REQUEST['scan'])){
$file = $_FILES["file"];
$upfos = new ieb_upload("file","../upload/".date('Y',time())."/".date('m',time())."/".date('d',time())."/");
$name = $upfos -> newName();
if ($id=='file'){
$uptypes = array('doc','zip','rar','xls','swf','docx');
if(!in_array($upfos -> getExt(), $uptypes)){
echo "<font color='red'>只能上传文件类型！只支持doc,zip,rar,xls,swf,docx等格式</font>";
exit;
}
}else{
$uptypes = array('image/jpg','image/jpeg','image/png','image/pjpeg','image/gif','image/bmp','image/x-png');
if(!in_array($file["type"], $uptypes)){
echo "<font color='red'>只能上传图像文件！</font>";
exit;
}
}
$upfos -> upload ($name);
if ($id<>'file'){
$upfos -> thumb('sm_', $w, $h);
}
echo '文件名称：' . $upfos -> getName() . '<br/>';
echo '文件类型：' . $upfos -> getExt() . '<br/>'; 
echo '文件大小：' . $upfos -> getSize() . '<br/>';
echo '随机文件：' . $upfos -> newName() . '<br/>';
?>
<input type="button" name="Submit" value="    确定添加    " id='exit' style="height:30px;">
<script type="text/javascript">  
document.getElementById('exit').onclick = function () {
	var origin = artDialog.open.origin;
	<? if ($id=='file'){?>
	var aValue = '<?=PL_URL;?>upload/<?=date('Y',time())."/".date('m',time())."/".date('d',time())?>/<?=$name;?>';
	var input = origin.document.getElementById('<?=$id?>');
	input.value = aValue;
	var aValues = '<?=$upfos -> getSize();?>';
	var inputs = origin.document.getElementById('kb');
	inputs.value = aValues;
	<? }else{?>
	var aValue = '<?=PL_URL;?>upload/<?=date('Y',time())."/".date('m',time())."/".date('d',time())?>/sm_<?=$name;?>';
	var input = origin.document.getElementById('<?=$id?>');
	input.value = aValue;
	<? }?>
	<? if($modname=='pic'){?>
	var aValues = '<?=PL_URL;?>upload/<?=date('Y',time())."/".date('m',time())."/".date('d',time())?>/<?=$name;?>';
	var inputs = origin.document.getElementById('big<?=$id?>');
	inputs.value = aValues;
	<? }?>
	input.select();
	art.dialog.close();
};

</script>
<?
}
?>
</body>
</html>
