<!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> OOPHP博客管理系统</title>
	<link rel="stylesheet" type="text/css" media="screen" href="<{$baseUrl}>/public/styles/layout.css" />
	<link rel="stylesheet" rev="stylesheet" type="text/css" media="screen, projection" href="<{$baseUrl}>/public/styles/pagenav.css" />
<script type="text/javascript" language="Javascript" src="<{$baseUrl}>/public/scripts/jquery.js"></script>
<script language="javascript" type="text/javascript">
//上傳的JS代碼
function uploadImg(id,fileid,formid){
	var formids=formid;
	var formid="#"+formid;
	
	var filepath=$('#uploadfile').val();
	  	if((filepath.indexOf("."))!==-1)  
	  	{		var get=filepath.lastIndexOf(".")+1;  
	         	var filetype=filepath.substring(get,filepath.length); 
	         	var filetype=filetype.toLowerCase();
	  	}
	  	var allow="jpg,gif,bmp,jpeg,png";
		var result=allow.indexOf(filetype);
		
	if(result>=0){
		
		 oldTarget=$(formid).attr('target');
		 oldAction=$(formid).attr('action');
		 oldOnsubmit=$(formid).attr('onsubmit');
		 $(formid).attr('target','uploadImgFrame');
		 $(formid).attr('action','<{$baseUrl}>/admin/photo/upload/');
		 $(formid).attr('onsubmit','');
		
		 $(formid).submit();
		 $(formid).attr('target',oldTarget);
		 $(formid).attr('action',oldAction);
		 $(formid).attr('onsubmit',oldOnsubmit);
	
	  }else{
		 	alert("对不起,您选择的上传文件不是有效的图片文件！");
		 	return false;
	  }
}

function delImages(filedimg,filedword,filedupload,url){
	if(confirm("您确定要删除吗?")){
	var filedimg="#"+filedimg;
	var filedword="#"+filedword;
	var filedupload="#"+filedupload;
	$.post('<{$baseUrl}>/admin/photo/delimage/',{'url':url}, function(data) {
		$(filedword).empty();
		$(filedimg).attr({ src: "<{$baseUrl}>/public/images/noimg.jpg", alt: "noimg.jpg" });
		$(filedupload).empty();
		$(filedupload).html("<th>相册图片</th><td colspan=\"2\"><p><input type=\"file\" name=\"uploadfile[]\" size=\"50\" id=\"uploadfile\"  /><input type=\"button\" name=\"Submit\"  onclick=\"uploadImg('1','fileupload1','uploadform');\" value=\"上传\" /></p></td>");
		
			
	});
	}	
	else{
		return false;	
	}
	
}
</script>


</head>

<body>
<div id="navbar">
    <p><!-- <span><select name=""><option value="0">后台首页</option></select></span> -->你的位置: <a href="main.html" title="">后台首页</a> &gt; 增加相片</p>
</div>
<div class="table-div">
    <form method="post" id="uploadform" enctype="multipart/form-data" action="<{$baseUrl}>/admin/photo/add/">
    <table>
	<thead>
	  <tr>
	    <th class="title" colspan="3">增加相片</th>
	  </tr>
	</thead>	
	<tbody>
      <tr>
	    <th style="width:15%;">相片名称</th>
		<td><input type="text" name="title" id="title" size="60" /></td>
		<td rowspan="5" style="text-align:center;">&nbsp;
		<img id="thisHeadImg" src="<{$baseUrl}>/public/images/noimg.jpg" width="150" height="150" />
		<p id="ImgInputSpan" style="text-align:center;"></p>  </tr>
	 
	  <tr>
	    <th>相片发布者</th>
		<td><input type="text" name="author"  id="author" value="kylingood" size="60" /></td>
	  </tr>
	   <tr>
	    <th>相册描述</th>
		<td><input type="text" name="content" id="content" size="60" /></td>
	  </tr>
	  
	    <tr>
	    <th>所在相册</th>
		<td><select id="albumid" name="albumid"  >
		<option  value="noalubmid">请选择相册</option>
		<{section name=albumList  loop=$albumAll}>
		<option  value="<{$albumAll[albumList].id}>"><{$albumAll[albumList].name}></option>
		<{sectionelse}>
		<option  value="noalubmid">暂无相册</option>
		 <{/section}>
		</select></td>
	  </tr>
	   <tr id="fileupload1">
	    <th>上传相片</th>
		<td colspan="2"><p>
		<input type="file" name="uploadfile[]" size="50" id="uploadfile"  /><input type="button" name="Submit"  onclick="uploadImg('1','fileupload1','uploadform');" value="上传" />
		</p></td>
	  </tr>
	  <tr>
	    <th colspan="3"><input type="submit" value="确定增加" class="cmd" /></th>
	  </tr>
	  </tbody>
	</table>
    </form>
<iframe name="uploadImgFrame" width="0" height="0" frameborder="0" id="uploadImgFrame"></iframe>
</div>
</body>
</html>