<?php 
require("../global.php");
require(R_P."require/f_uploads.php");
session_start();
InitGP(array('admin_up','action','id',));
//unset($_SESSION['img']);
if ($action == 'delImg') {
	unlink(R_P.$_SESSION['img'][$id]);
	unset($_SESSION['img'][$id]) ;
	echo  "<script language=javascript type=text/javascript>history.back();</script> ";
}
elseif (!empty($_FILES['img']) && !empty($_SESSION['user_name'])) {
	if (count($_SESSION['img'])>=5) {
		echo  "<script language=javascript type=text/javascript>alert('已经超出图片上传的额度，不能上传图片！');history.back();</script> ";
	}
	else {
 
		for ($I=5;$I>=1;$I--){
			if (empty($_SESSION['img'][$I])) {
				$up_dir_str = up_type('img',$up_dir);
				$_SESSION['img'][$I] = $up_dir_str ;
				break;
			}
		}

		echo  "<script language=javascript type=text/javascript>alert('本次您已经上传了(".count($_SESSION['img']).")张！');history.back();</script> ";

	}
}

else{


	print <<<EOT
<html>
<head>
<title>上传</title>
<meta http-equiv="Content-Type" content="text/html; charset={charset}">
<link href="/css/css.css" rel="stylesheet" type="text/css" />
</head>
<body  bgcolor="#FEFAC8" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload=parent.document.all.classpage.height=document.body.scrollHeight>
<form action=""  enctype="multipart/form-data" method="POST" >
上传文件：<input type="file" style="width=300px" name="img"> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="上  传"> 
<input type="reset" value="重  选"> 
<br>
EOT;

	if (!empty($_SESSION['img'])) {
		foreach ($_SESSION['img'] as $key=>$value) {
			if ($value) {
				print <<<EOT
		<img src="../$value" width=80 height=80> 
		<a href="javascript:if(confirm(' 您真的要删除这张图片吗? ')){location='?action=delImg&id=$key';}">删除</a>
EOT;
}
}
}


print <<<EOT
</form>
</body>
</html>
EOT;
}
?>
