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:
commons.jsp


boolean isMultipart = FileUpload.isMultipartContent(request);

DiskFileUpload upload = new DiskFileUpload();

upload.setRepositoryPath("C:\\data\\");
upload.setSizeMax(-1);

List items = upload.parseRequest(request);

Iterator itr = items.iterator();

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

        } else {

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to