多文件上传

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title>My JSP 'struts2Upload.jsp' starting page</title>
 
 <script type="text/javascript">
  function addMore(){
  
   var td = document.getElementById("more");
   var br = document.createElement("br");
   var input = document.createElement("input"); 
   var button = document.createElement("input");
   
   input.type="file";
   input.name="file1";
   
   button.type="button";
   button.value="remove"
   
   button.onclick = function (){
    td.removeChild(br);
    td.removeChild(input);
    td.removeChild(button); 
    
   }
   
   td.appendChild(br);
   td.appendChild(input);
   td.appendChild(button); 
   
  }
  
 </script>
 
  </head>
 
  <body>

        <s:form action="strutsUpload"  method="post" enctype="multipart/form-data" theme="simple">
   
    <table align="center" width="60%" border="1"> 

 

             <tr>
          <td>file</td>
         
          <td id="more">
           <s:file name="file1"></s:file><input type="button" value="add More.." onclick="addMore()">
          </td>
         </tr>

 

    </table>

 

  </body>
</html>

你可能感兴趣的:(JavaScript,html,jsp,struts)