jquery dynamically add dynamic Add File upload box and dynamic delete upload box
<script type= "Text/javascript" >$ (function () { $ ("#button"). Click (function () { var html = $ ("<input type= ' file ' Name= ' upload ' > '); var button = $ ("<input type= ' button ' name= ' button ' value= ' delete ' ><br > "); $ ("#div"). AppendChild (HTML). appendchild (Button); &nbSp; button.click ( function () { html.remove (); button.remove (); }) }) }) </script><form action = "${ Ctx}/order/upload.action " method=" post " enctype=" Multipart/form-data "><input name=" upload " type=" File "><input type=" button " value=" Add " id=" button "><br><div Id= "Div" ></div><button> Submit </button></form>
Background code:
private list<file> upload;private list<string> uploadcontenttype;private List<string> uploadfilename;public string upload () { //Server store upload file directory String destpath = servletactioncontext.getservletcontext (). Getrealpath ("/upload"); System.out.println (DestPath); file file=new file (DestPath); if (!file.exists ()) file.mkdirs (); system.out.println (file); try { for (Int i=0;i<upload.size (); i++) { fileutils.copyfile (upload.get (0), new file (File,uploadfilename.get (i))); } } catch (ioexception e) { e.printstacktrace (); return ERROR; } return SUCCESS; }
Reference article:
Http://www.cnblogs.com/xiaoluo501395377/archive/2012/10/26/2740882.html
Strut 2 Single File upload:
http://tianxingzhe.blog.51cto.com/3390077/1681576
This article is from the "Nothing-skywalker" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1681604
Strut multiple file uploads