小弟没头绪,请各位高手指点迷津,谢谢!
解决方案 »
- 为什么我用hibernate连接SQL 2005 他报错
- java反射获取父类的属性
- JFrame初始位置能不能定义??
- 菜鸟发问:关于swing中的jtable添加数组的问题!!!?请知道的帮忙解决哈!!谢谢!!!
- 跪求jsp金额大小写转换代码!谢谢
- 怎么在jsp页面上得到当前的年月日小时分秒
- 如何设置Date类的显示格式为"1998-09-01 12:02:33"这种格式!
- 听说 Java 2 核心技术 卷II:高级性能要出第6版了?
- 如何将一串字符写入文件中 (100分)
- 图片和jlabel的大小不相同,怎样让图片充满整个jlabel?
- InstallAnywhere 8 Enterprise 如何打包程序中的参数
- 一个随机数设计,可不可以实现?
上传有很多类库可以用的,比如jspUpload等等,很多的,google一下吧_________________
技术圈:IT人的家
这个是JSP页面 <tr>
<th align="center" bgcolor="#ffffff" scope="row">
<div id="cz">
<input type="button" name="czbutt" class="input3" value="承装类上传资料" onClick="czsq()" disabled></div>
</th>
</tr>function czsq()
{
var url='czsq.jsp';
window.open(url,'newwindow','height=600,width=925,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
}。。
这里是指向的上传页面
<%@ page language="java" contentType="text/html; charset=gbk" import="com.jspsmart.upload.*" %>
<!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=gb2312">
<title>企业技术及管理人员导入页面</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #F0F9FF;
}
.style2 {color: #15427F}
td {
font-size: 12px;
line-height: 150%;
color: #333333;
text-decoration: none;
}
.style3 {color: #FF0000}
a {
font-size: 12px;
line-height: 150%;
color: #052B77;
text-decoration: none;
}
.style4 {color: #999999}
.style6 {font-size: 13px}
.a4 { font-size: 12px;
line-height: 120%;
color: #555555;
text-decoration: none;
}
.a6 { font-size: 12px;
line-height: 120%;
color: #0000FF;
text-decoration: none;
}
.input2 {
BACKGROUND: #ffffff; BORDER-BOTTOM: #278CD8 1px solid; BORDER-LEFT: #278CD8 1px solid; BORDER-RIGHT: #278CD8 1px solid; BORDER-TOP: #278CD8 1px solid; COLOR: #1667BC; FONT-FAMILY: "arial"; FONT-SIZE: 12px
; height: 16px; width: 140px}.input3 {
BACKGROUND: #ffffff; BORDER-BOTTOM: #B3CCE8 1px solid; BORDER-LEFT: #B3CCE8 1px solid; BORDER-RIGHT: #B3CCE8 1px solid; BORDER-TOP: #B3CCE8 1px solid; COLOR: #1667BC; FONT-FAMILY: "arial"; FONT-SIZE: 12px
; height: 16px; width: 140px}
.input4 {
BACKGROUND: #2171C5; BORDER-BOTTOM: #f4f4f4 1px solid; BORDER-LEFT: #f4f4f4 1px solid; BORDER-RIGHT: #f4f4f4 1px solid; BORDER-TOP: #f4f4f4 1px solid; COLOR: #ffffff; FONT-FAMILY: "arial"; FONT-SIZE: 12px
; height: 20px; width: 60px}</style>
<script type="text/javascript">
function reSize()
{
window.resizeTo(500,300);
window.moveTo(300,300);
}
</script>
</head>
<body onload="reSize()">
<FORM name="czfrm" METHOD="POST" ACTION="uploadCz.jsp" ENCTYPE="multipart/form-data">
<table width="98%" border="0" align="center" cellpadding="0"
cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td height="40" background="images/bg04e.gif" bgcolor="#BDDBEE">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>上传附件
<input type="FILE" name="FILE1" size="30">
<input type="submit" name="Submit" value="上传" >
</td>
</tr>
</table>
</td>
</tr>
</table>
</FORM>
<form name="czfr2">
<table width="98%" border="0" align="center" cellpadding="0"
cellspacing="1" bgcolor="#FAFAD2">
<tr>
<td>
上传说明:
</td>
</tr>
<tr>
<td>
<pre>
说明1:企业的承装等级上传附件以及资料。
说明2:如果上传类别几种,可以依次上传。
说明3:例如上传承装3级的资料,把所有的
资料打包放到一个文件夹中,文件夹名字取
名为:承装三级,依次类推!
</pre>
</td>
</tr> </table>
</form>
<%
if(session.getAttribute("uploadOk") !=null)
{
out.println((String)session.getAttribute("uploadOk"));
session.setAttribute("uploadOk",null);
}
%>
</body>
</html>这里是实现页面<%@ page contentType="text/html; charset=gbk" language="java"
import="com.jspsmart.upload.*,
java.util.*" %>
<html>
<head>
<title>文件上传处理页面</title>
</head>
<body>
<form name="CzloadFrm" >
<%
String djbno =(String)session.getAttribute("djbno");
System.out.println("电监办ID:"+djbno);
String path="";
try
{
String separator = null;
java.util.Properties p = new Properties(System.getProperties());
String osName = p.getProperty("os.name");
java.io.File upfile=new java.io.File(djbno+"\\cz");
//判断操作系统
if(osName.indexOf("Win")!=-1)
{
separator = "\\";
if(!(upfile.isDirectory()))
{
upfile.mkdirs();
}
path = djbno+"//"+"cz";
}
else if(osName.indexOf("AIX")!=-1)
{
separator = "/";
if(!(upfile.isDirectory()))
{
upfile.mkdirs();
}
path=djbno+"//"+"cz";
}
System.out.println("cyPath: "+upfile.getAbsolutePath());
session.setAttribute("FilePath",upfile.getAbsolutePath()); if(separator==null)
{
return;
}
//实例化上载bean
SmartUpload su = new SmartUpload();
//上传初始化
su.initialize(pageContext);
// 设置上载的最大值
// su.setMaxFileSize(500 * 1024*1024);
//上载文件
// mySmartUpload.setAllowedFilesList("doc,txt"); //上传限制扩展名
// su.setAllowedFilesList("doc");
// 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat, jsp,htm,html扩展名的文件和没有扩展名的文件。
// su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
su.upload();
// 循环取得所有上载的文件,由于刚才的上传选择文件网页upload,htm只有一个文件所以只循环一次,
//如果需要一次上传多个文件,则修改upload,htm,增加多个文件选择INPUT
for (int i=0;i<su.getFiles().getCount();i++)
{
// 取得上载的文件
com.jspsmart.upload.File myFile = su.getFiles().getFile(i);
// 若文件不存在则继续
if (myFile.isMissing()) continue;
//保存文件
try{
myFile.saveAs(path+separator+myFile.getFileName());
System.out.print("path="+path+"\n"+"myfile.getFileName上传文件是:"+myFile.getFileName());
}catch(SmartUploadException esm){esm.printStackTrace();}
}
String uploadOk= "\n<Script language=\"javaScript\"> alert('上传成功!');</Script>";
session.setAttribute("uploadOk",uploadOk);
response.sendRedirect("czsq.jsp");
}
catch(Exception err)
{
err.printStackTrace();
}%>
</form>
</body>
</html>OK了,你整理下就没有问题了 记得给分哦