commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Forte, Graham" <graham.fo...@ngc.com>
Subject RE: commons newbie
Date Tue, 30 Mar 2004 16:04:03 GMT
Thanks Laurent that worked!

One other question.
The code below works fine except for 1 problem,
The file is being saved as upload_00000024.tmp
How can I force the file to retain its original name?

[code]

boolean isMultipart = FileUpload.isMultipartContent(request);

DiskFileUpload upload = new DiskFileUpload();

upload.setRepositoryPath("C:\\data\\");

List items = upload.parseRequest(request);

Iterator itr = items.iterator();

while(itr.hasNext()) {
	FileItem item = (FileItem) itr.next();
        
	if(item.isFormField()) {
            
	String fieldName = item.getFieldName();
	
	if(fieldName.equals("name"))
		request.setAttribute("msg", "Thank You: " + item.getString());
		
	} else {

		File fullFile  = new File(item.getName());  
		File savedFile = new File(getServletContext().getRealPath("/"),
		fullFile.getName());
		item.write(savedFile);
	}
}
[/code]

TIA!

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


Mime
View raw message