<form enctype='multipart/form-data' method='POST' action='submit.jsp'>
<input type='file' name='files[]' multiple />
<button type='submit'>Submit</button>
I have written this code in my IDE .
Then ,on submit page , I am trying to access the multiple files uploaded in the form ..they are saved in the folder easily with multipartrequest object but when I am trying to save their names to database ,only last file name is saved.. I am not getting the code to extract all the file names and save them to a database.
Asked
Active
Viewed 248 times
0

Jain
- 1
-
Can you show your `submit.jsp` page as well ? – Swati Sep 27 '20 at 05:46
-
String root=getServletContext().getRealPath("folder"); MultipartRequest mr = new MultipartRequest(request,root); Enumeration files=mr.getFileNames();. String name=(String)files.nextElement(); String fileName=mr.getFilesystemName(name);. out.print(fileName); ...for now I m trying to just print all file names ..to check if all are accessible – Jain Sep 27 '20 at 06:01
-
You need to loop through your files and save one at time using batch maybe .Refer [this](https://stackoverflow.com/a/4355097/10606400) answer might help. – Swati Sep 27 '20 at 06:18
-
Yes ,for saving in database , I will try to use batch but at least I should get all the file name to ensure they are accessible ,then only they will be saved na – Jain Sep 27 '20 at 06:25
-
How can I loop through the files – Jain Sep 27 '20 at 06:29
-
For that check [this](https://stackoverflow.com/a/29606549/10606400) answer. – Swati Sep 27 '20 at 06:55