日期:2014-05-18  浏览次数:20763 次

怎样用JspSmartUpload实现文件上传攻略?
㈠   表单要求  


对于上传文件的FORM表单,有两个要求:  


1、METHOD应用POST,即METHOD= "POST "。  


2、增加属性:ENCTYPE= "multipart/form-data "  


下面是一个用于上传文件的FORM表单的例子:  


<FORM   METHOD= "POST "   ENCTYPE= "multipart/form-data "  
ACTION= "/jspSmartUpload/upload.jsp ">
<INPUT   TYPE= "FILE "   NAME= "MYFILE ">
<INPUT   TYPE= "SUBMIT ">
</FORM>
 


㈡   上传的例子  


1、上传页面upload.html  


本页面提供表单,让用户选择要上传的文件,点击 "上传 "按钮执行上传操作。  


页面源码如下:  


<!--
        文件名:upload.html
作     者:纵横软件制作中心雨亦奇(zhsoft88@sohu.com)
-->
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
<head>
<title> 文件上传 </title>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
</head>

<body>
<p> &nbsp; </p>
<p   align= "center "> 上传文件选择 </p>
<FORM   METHOD= "POST "   ACTION= "jsp/do_upload.jsp "
ENCTYPE= "multipart/form-data ">
<input   type= "hidden "   name= "TEST "   value= "good ">
    <table   width= "75% "   border= "1 "   align= "center ">
        <tr>  
            <td> <div   align= "center "> 1、  
                    <input   type= "FILE "   name= "FILE1 "   size= "30 ">
                </div> </td>
        </tr>
        <tr>  
            <td> <div   align= "center "> 2、  
                    <input   type= "FILE "   name= "FILE2 "   size= "30 ">
                </div> </td>
        </tr>
        <tr>  
            <td> <div   align= "center "> 3、  
                    <input   type= "FILE "   name= "FILE3 "   size= "30 ">
                </div> </td>
        </tr>
        <tr>  
            <td> <div   align= "center "> 4、  
                    <input   type= "FILE "   name= "FILE4 "   size= "30 ">