commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Amit.Malp...@sungard.com>
Subject RE: [fileupload]
Date Thu, 10 Mar 2011 14:20:55 GMT
Sure chris.

Libraries I have used:

1. commons-io-2.0.1.jar
2. commons-fileupload-1.2.2.jar

Following is the servlet code:

// Create a factory for disk-based file items
			DiskFileItemFactory factory = new
DiskFileItemFactory();

			// Set factory constraints
			factory.setSizeThreshold(10000000);
			factory.setRepository(new File("C:\\uploads"));

			// Create a new file upload handler
			ServletFileUpload upload = new
ServletFileUpload(factory);

			// Set overall request size constraint
			upload.setSizeMax(10000000);

			// Parse the request
			List /* FileItem */ items =
upload.parseRequest(request);
			
			System.out.println("items no: " + items.size());
			
			// Process the uploaded items
			Iterator iter = items.iterator();
			
			boolean writeToFile = true;
			
			while (iter.hasNext()) 
			{
			    FileItem item = (FileItem) iter.next();
			    String fileName = item.getName();

			    System.out.println(fileName);
			    
			 // Process a file upload
			    if (writeToFile) 
			    {			    	
			        File uploadedFile = new
File("C:\\uploads\\" + FilenameUtils.getName(fileName));
			        item.write(uploadedFile);
			        
			    } else 
			    {
			        InputStream uploadedStream =
item.getInputStream();			        
			        uploadedStream.close();
			    }
			}

That's all

Amit

-----Original Message-----
From: christopher.alexander@novartis.com
[mailto:christopher.alexander@novartis.com] 
Sent: Thursday, March 10, 2011 7:19 PM
To: Commons Users List
Subject: RE: [fileupload]

Hi Amit,

Would you mind posting the code and list of libraries that is 
accomplishing the single file upload. If I can replicate this, maybe I
can 
assist in establishing multiple file upload. :)

Chris




<Amit.Malpure@sungard.com> 
03/10/2011 01:28 AM
Please respond to
"Commons Users List" <user@commons.apache.org>


To
<user@commons.apache.org>
cc

Subject
RE: [fileupload]






Yes, I am able to upload single file at a time. But want to upload
multiple files at one go.

Amit

-----Original Message-----
From: christopher.alexander@novartis.com
[mailto:christopher.alexander@novartis.com] 
Sent: Thursday, March 10, 2011 2:37 AM
To: Commons Users List
Subject: Re: [fileupload]

Hi Amit,

To be truthful, I never got the damn thing working. Has anyone out there

actually been able to successfully get commons fileupload working?

Chris




<Amit.Malpure@sungard.com> 
03/09/2011 06:22 AM
Please respond to
"Commons Users List" <user@commons.apache.org>


To
<user@commons.apache.org>
cc

Subject
[fileupload]






I want to upload multiple files at a time using commons file upload jar.

 

How can I do it?

 

Thanks

Amit




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message