文件上传(使用smart包)

/**************************************
*Author:Java619
*Time:2005.10
**************************************/

文件上传也是我们经常用到的部件,这边我将使用Smart包,作个例子

1.上传页面index.htm

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< TITLE >  文件上传  </ TITLE >
< META  NAME ="Generator"  CONTENT ="EditPlus" >
< META  NAME ="Author"  CONTENT ="" >
< META  NAME ="Keywords"  CONTENT ="" >
< META  NAME ="Description"  CONTENT ="" >
</ HEAD >

< BODY >
< FORM  METHOD =POST  NAME ="theForm"  ACTION ="" >
< iframe  name ="ad"  frameborder =0  width =300  height =40  scrolling =no  src ="FileUpload.html" ></ iframe >
</ FORM >
</ BODY >
</ HTML >

2.FileUpload.html文件


< html >
< head >
< title > Untitled Document </ title >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312" >
< style  type ="text/css" >
<!--
body 
{
    background-color
: #e8f4ff;
}

INPUT.fminpt 
{
    BORDER-TOP-WIDTH
: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #466184; BACKGROUND: none transparent scroll repeat 0% 0%; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #466184; FONT: menu; COLOR: #e056dd; BORDER-TOP-COLOR: #466184; FONT-FAMILY: MS Shell Dlg,Tahoma, sans-serif; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #466184
}

-->
</ style ></ head >

< body >

< script >
<!--
parent.theForm.Submit.disabled
=false;
parent.theForm.Submit2.disabled
=false;
-->
</ script >

< form  action ="upload.jsp"  method ="post"   enctype ="multipart/form-data" >
< table >< tr >< td >
< input  name ="file2"  type ="file"  class ="fminpt"  size ="20" >
< input  type ="submit"  class ="fminpt" onclick ="parent.theForm.Submit.disabled=true,parent.theForm.Submit2.disabled=true"  value ="上传" ></ td ></ tr >
</ table >
</ form >

</ body >
</ html >

3.上传处理文件upload.jsp

<% @ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage=""  %>
<% @ page import="com.jspsmart.upload.*" %>
< jsp:useBean  id ="mySmartUpload"  scope ="page"  class ="com.jspsmart.upload.SmartUpload"   />  
< html >
< head >
< title > 上载附件  </ title >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312" >
</ head >
< body >
<%

//上载附件

try
{

mySmartUpload.initialize(pageContext); 
mySmartUpload.service(request,response); 
mySmartUpload.upload(); 
String fn=fn=mySmartUpload.getFiles().getFile(0).getFileName();
mySmartUpload.save(
"upload/");//文件保存的目录为upload
out.println(
"已经成功上传了文件");
}
catch(Exception e)
{
e.printStackTrace();
}

%>
< href =FileUpload.html > 点击确认 </ a >
</ body >
</ html >

好到这边一个上传部件做好了,测试下吧!

上面用的com.jspsmart.upload包可到

www.jspsmart.com下载

或发E-mail到ceunlove@163.com索取,注明索取com.jspsmart.upload包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值