javascript - Get files from cloned rows in jsp -
i want uploaded files jsp java servlet. using multipartrequest files , other form details.
<script type="text/javascript"> function clonerow() { var newrow = $("#tabletomodify tr:last").clone(true).find(':input').val('').end(); $("#tabletomodify").append(newrow); table.appendchild(newrow); } function deleterow(o) { var p = o.parentnode.parentnode; p.parentnode.removechild(p); } </script> <body id="mydiv" class="animate-bottom"> <form method="post" action="testcontroller" enctype="multipart/form-data"> <table class="table table-bordered custom-table"> <tbody id="tabletomodify"> <tr> <th scope="col"><span>visitor name </span><span style="color:red">* </span></th> <th scope="col">upload photo</th> <th scope="col"><input type="button" onclick="clonerow()" value="add visitor" /> </tr> <tr id="clonerow"> <td><input name="visior_name" type="text" maxlength="30" oninput="this.value = this.value.replace(/[^a-za-z\s]/g, '');" id="contentplaceholder2_grd_visitor_details_txt_visior_name_0" class="form-control-custom" style="width:150px;" required/></td> <td><input type="file" name="upload" style="width:150px;" /></td> <td> <a href="#" onclick="deleterow(this)"></a> <span class="glyphicon glyphicon-remove"></span> </a> </td> </tr> </table> </form> </body>
this jsp page used clone rows , add files. last uploaded file's name printed in console when used
multipartrequest mreq = new multipartrequest(request, "d:/pics", 1024 * 1024 * 1024); enumeration files = mreq.getfilenames(); while (files.hasmoreelements()) { system.out.println("\nhasmoreitems"); string name = (string) files.nextelement(); string filename = mreq.getfilesystemname(name); system.out.println(filename);
this loop gets executed once files overrided in enumeration files.
please me in getting files upload in same order. , want done multipartrequest
Comments
Post a Comment