Multiple file upload


Multiple file upload

View Answers

December 28, 2008 at 11:31 PM

Hi friend,

Code to help in solving the problem :

<head><title>Upload page</title></head></p> <p><body>
<form action="upload_file_multipale.jsp" method="post" enctype="multipart/
form-data" name="form1" id="form1">
<table border="2">
<td align="center"><b>Multipale file Uploade</td>
Specify file: <input name="file" type="file" id="file">
Specify file:<input name="file" type="file" id="file">
Specify file:<input name="file" type="file" id="file">
<td align="center">
<input type="submit" name="Submit" value="Submit files"/>


<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="" %>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<center><table border="2">
<tr><td><h1>Your files uploaded </h1></td></tr>
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
} else {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem);
if (item.isFormField()) {
} else {
try {
String itemName = item.getName();
File savedFile = new File(config.getServletContext

out.println("<tr><td><b>Your file has been saved
at the loaction:</b></td></tr><tr><td><b>"+config.getServletContext().getRealPath
} catch (Exception e) {


December 29, 2008 at 3:37 AM

The code above will work only with servlets and i m using struts.
I have this implemeted in servlets but now i have to do this with struts.

In this "items = upload.parseRequest(request);" will not be able to do.

So plz suggest me some other way out.


December 30, 2008 at 5:49 AM


HI all,

I have found the solution.the code is given below:

In jsp use : enctype="multipart/form-data" method="post"

<logic:iterate name="FormBean" property="dataDisp" id="dataDisp" indexId="id">

<td class="class1">
<input type="file" name = "dataDisp[<%=id %>].ffFile" id="dataDisp[<%=id %>].ffFile" />

where dataDisp is a seperate bean whose object we are placing in an array in the main from bean.

Thanks all for the suggestions.


Related Tutorials/Questions & Answers:
Multiple File Upload in PHP
Multiple File Upload in PHP  Hi, I am beginner in PHP scripting language. I am very interested to learn PHP application. So, can anyone explain or provide related reference about how to Multiple file upload in PHP. Thanks
Multiple file upload - Struts
Multiple file upload  HI all, I m trying to upload multiple files... need to upload is dynamically generated. I have tried using formfile. and also... in solving the problem : Upload page
multiple file upload at a time like gmail
multiple file upload at a time like gmail  I want to upload multiple files at a time like gmail. is there any possiblity/solution to do that?   Hi Friend, Please visit the following link: Upload Multiple Files Thanks
Source file upload by attaching multiple files
Source file upload by attaching multiple files  Hi, I am trying to develop a file upload with multiple files attached functionality in java(like in gmail or in picasa). The source I found so far will select a single file. When I
Source file upload by attaching multiple files
Source file upload by attaching multiple files  Thanks for the answer. The answer posted in this link I want to have a single text box and when i... a provision to attach multiple images/files like in gmail. Is there any solution
how to upload multiple files in jsp and saving the path in database and the file in folder
how to upload multiple files in jsp and saving the path in database and the file in folder  how to upload multiple files in jsp and saving the path in database and the file in folder I have created a form for the upload of files
Upload and Download multiple files
Upload and Download multiple files  Hello Sir/Madam, I need a simple code for upload and download multiple files(it may be image,doc... link:
File Upload
File Upload  when i execute the image upload to mysql database it shows an exception that file path cannot be found
jsp upload file to server
jsp upload file to server  How to create and upload file to server in JSP?   Find the given example that explains how to upload single and multiple file on server using JSP
Multiple upload - JSP-Servlet
Multiple upload  Hello everyone and Deepak i am using jsp and mysql I am using the program published on of Multiple upload and i am facing an error as given below please help and reply soon this is my 8th
Multiple image upload using JSP
Multiple image upload using JSP  I have written a code to upload... type="file" name="file[]" multiple > <INPUT type="submit" value="Send... + File.separator + user_name; > > if (!(new File(fileSavePath_upload_dir
File Upload in Struts.
File Upload in Struts.  How to do File Upload in Struts
File Upload
File Upload  Hi I need script / string in PHP where I uploaded the file in html frontend and it should sent the uploaded file as attachment to my email address
file upload
file upload  how to recieve the uploaded file on the next jsp page for modification if its uploaded to the previous page using a from
File Upload - JSP-Servlet
File Upload  Hi everyone, I am facing file uploading problem.the multiple file upload code of roseindia is working on localhost but the same code is not working on server.i think the package commons-fileupload-1.2.jar
upload and save the file
upload and save the file  upload and save a file from a computer to specific location of remote computer using jsp
servlet file upload
servlet file upload  please tell me the complete code to upload a file on localhost using servlet
AJAX file upload
AJAX file upload If you want to upload file asynchronously means without... Demo URL Description You need to create a form with file fields you wish to upload and define
upload a file - Framework
upload a file  Hi to All, I need to upload a file from the client and that upload file should be sent to our co., mail please if any one provide.... Thankyou in Advance.  Hi friend, For upload a file in JSP visit
Upload file to MS Access
Upload file to MS Access  Iam beginner and need to upload file to msaccess using jsp . Iam using netbeans platform. Kindly explain do I need to mention Attachment format in the table
Struts upload file - Framework
Struts upload file  Hi, I have upload a file from struts... and send to file upload to get the sheets and data in that sheets Thanks.  Hi friend, For upload a file in struts visit to : http
Upload file with ather Fieldn
Upload file with ather Fieldn  hello i want upload file with other record to database for my project,like that (FileID, Filename,Filedescrption,Filedate,file_upload) see( upload file with path) i can send data to database
file upload in spring - Spring
file upload in spring  Is it necessary to use Multipart support in spring framework for file uploads.If not please let me know the other ways to do
File Upload and Retrive files
File Upload and Retrive files  Can any body help me am getting an error in uploading file. into mysql database.... thank's in advance
file upload plugin in jquery
file upload plugin in jquery  file upload plugin in jquery   You can use the following code to use the JQuery plugin. $(document).ready(function() { $("#uploadbutton").jsupload({ action: "
File upload in JSP
File upload in JSP  hi! In my previous interview i got two questions which i could not answer regarding file upload and annotations. I want to know which is the best method can be used for file upload. Whether moving them
Java upload file to ftp
Java upload file to ftp  Hi, How to uploaded file to a ftp server in Java? Thanks   Hi, It's very easy to write a program in Java.... View complete example at FTP File Upload in Java Thanks
file upload using spring - Spring
file upload using spring  How to upload a file in server using spring framework
File upload - JSP-Servlet
File upload  I am trying to do a file upload program. But, it shows... ----------------------------------------------------------------------------- Display file upload form to the user <... the file To Upload
Ajax file upload
Ajax file upload  I am developing a application for image upload using ajax and servlet. The image should be converted in byte[] and must be saved in oracle databse as blob. After uploading the image it should be displayed
Image upload file - JSP-Servlet
:// Thanks...Image upload file  I want a code for image upload jsp or servlet