用于附件上传和管理的jsp页面
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>附件管理</title>
<jsp:useBean id="DispContro" scope="page" class="edu.scnu.crjy.common.DispContro"></jsp:useBean>
<script language="javascript">
//选择附件类型,更改附件目录以供查看

function changDir(obj)...{
var valueStr=obj.options[obj.selectedIndex].value

if(valueStr=="nul")...{
alert("请选择附件类型");
return false;

}else...{
document.location.href="./appendfileslist.jsp?childDir="+valueStr
}
}
//提交附件上传并检查附件了型,以上传到相应的附件目录中

function subm(obj)...{
var valueStr=obj.upDir.options[obj.upDir.selectedIndex].value

if(obj.appendfile.value=="")...{
alert("请选择要上传的附件")
return false;
}

if(valueStr=="nul")...{
alert("请选择附件类型");
return false;

}else...{
obj.action="./body/appendfilebody.jsp?childDir="+valueStr
return true;
}
}
//选择所有显示的附件

function selectAll()...{
var check=document.getElementsByName("checkAppendFile")

for(i=0;i<check.length;i++)...{

if(!check[i].checked)...{
check[i].checked=true
}
}
return false;
}
//取消选择所有附件

function cancerAll()...{
var check=document.getElementsByName("checkAppendFile")

for(i=0;i<check.length;i++)...{

if(check[i].checked)...{
check[i].checked=false
}
}
return false;
}
//删除选择的所有附件

function delAll()...{
var check=document.getElementsByName("checkAppendFile")
var i=check.length
var checkList=""

if(i==0)...{
return false;
}

for(j=0;j<i;j++)...{

if(check[j].checked)...{
checkList=checkList+"@"+check[j].value
}
}

if(!checkList=="")...{
document.all.delall.value=checkList
var url="./body/delappendfile.jsp"
window.open(url,"delappendfile","title=no,width=50,height=50,memu=no,resize=no,toolbar=no")

}else...{
alert("请选择要删除的附件")
return false;
}
}
</script>
</head>
<body>
<center>
<form ENCTYPE="multipart/form-data" action="" onsubmit="return subm(this)" method="POST">
<table width="70%">
<tr>
<td width="150" align="center">上传附件:</td>
<td align="left"><input style="width:100%" type="file" value="" name="appendfile" id="appendfile"></td>
</tr>

<tr>
<td align="center">
<input type="submit" name="submit" text="上传" value="上传">
<input type="reset" name="cancer" text="取消" value="取消">
</td><td>
<select name="upDir" >
<option value="nul">请选择上传附件类型</option>
<option value="docs">文档</option>
<option value="pics">图片</option>
<option value="flashs">动画</option>
<option value="others">其它</option>
</select>
</td>
</tr>


</table>

</form>
</center>
<center>
<table border="1">
<tr><td colspan="5">
<select onChange="changDir(this)" name="selectDir" >
<option value="nul">请选择上传附件类型</option>
<option value="docs">文档</option>
<option value="pics">图片</option>
<option value="flashs">动画</option>
<option value="others">其它</option>
</select>
<input type="button" onClick="selectAll()" value="全选">
<input type="button" onClick="cancerAll()" value="取消全选">
<input type="button" onClick="delAll()"value="删除选择">
<input type="hidden" name="delall">
</td></tr>
<%

String[] filesList;
String documentRoot,childDir,tdStr;
int j,i;
j=i=0;
childDir=request.getParameter("childDir");

if(childDir==null)...{
childDir="pics";
}
tdStr="";
documentRoot=getServletContext().getRealPath("/")+"appendfiles/"+childDir;
//out.println(documentRoot);
java.io.File rootFolder=new java.io.File(documentRoot);

filesList=rootFolder.list();

for(i=0;i<filesList.length;i++)...{

if(!filesList[i].equals("Thumbs.db"))...{
j++;
tdStr=tdStr+"<td align='center'>";
tdStr=tdStr+"<input name='checkAppendFile' type='checkbox' value='";
tdStr=tdStr+childDir+"/"+filesList[i]+"'>";
tdStr=tdStr+DispContro.getAppendFilesDispStr(childDir,filesList[i]);
tdStr=tdStr+"<br>"+filesList[i]+"</td>";

if(j==4)...{
out.println("<tr>"+tdStr+"</tr>");
tdStr="";
j=0;
}
}
}

if(j<4)...{

for(i=0;i<(4-j);i++)...{
tdStr=tdStr+"<td> </td>";
}
out.println("<tr>"+tdStr+"</tr>");
}
%>
</center>
</body>

</html>





































































































































































































