commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Forte, Graham" <>
Subject [File Upload] specifying the directory to upload to
Date Tue, 30 Mar 2004 17:50:45 GMT
I am trying to use commons 1.0 final to accomplish file uploads. So far it works. I need to
have the upload directory be a directory other than the webapps/myapp/ directory. I initially
specified the directory using: upload.setRepositoryPath("C:\\data\\");
This worked initially(except that it renamed the file to upload_00000024.tmp) but then stopped
working and I cant figure out what I did to make it stop. I am using a jsp to upload the files
and it is similar to the commons example. Currently it is uploading the file to the app root
directory webapps/myapp/  in tomcat 4.1. 
Any help is appreciated.

Here is my code:

boolean isMultipart = FileUpload.isMultipartContent(request);

DiskFileUpload upload = new DiskFileUpload();


List items = upload.parseRequest(request);

Iterator itr = items.iterator();

while(itr.hasNext()) {
	FileItem item = (FileItem);
	if(item.isFormField()) {
	String fieldName = item.getFieldName();

	} else {

		File fullFile  = new File(item.getName());  
		File savedFile = new File(getServletContext().getRealPath("/"),fullFile.getName());

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message