Yes, I got this from onjava.com. Should I get rid of that? I just moved this to another machine and now I get a new error :
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\uploadSum_jsp.java:9: package org.apache.commons.fileupload does not exist import org.apache.commons.fileupload.*; I put the jar file under /webapps/ROOT/WEB-INF/lib/ I am using ROOT as my app. For some reason It does not see it. Thanks! -----Original Message----- From: Schalk [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 30, 2004 1:48 PM To: 'Jakarta Commons Users List' Subject: RE: [File Upload] specifying the directory to upload to Graham With this line: File currentFile = new File(getServletContext().getRealPath("/"),fullFile.getName()); You are probably trying to get the name of the file being uploaded without any folder or separator information, correct? Kind Regards Schalk Neethling Web Developer.Designer.Programmer.President Volume4.Development.Multimedia.Branding emotionalize.conceptualize.visualize.realize Tel: +27125468436 Fax: +27125468436 email:[EMAIL PROTECTED] web: www.volume4.com This message contains information that is considered to be sensitive or confidential and may not be forwarded or disclosed to any other party without the permission of the sender. If you received this message in error, please notify me immediately so that I can correct and delete the original email. Thank you. :: -----Original Message----- :: From: Forte, Graham [mailto:[EMAIL PROTECTED] :: Sent: Tuesday, March 30, 2004 9:41 PM :: To: 'Jakarta Commons Users List' :: Subject: RE: [File Upload] specifying the directory to upload to :: :: Schalk thanks for your reply. :: That was helpful, however I am now getting a nullpointerexception which points to: :: :: java.lang.NullPointerException :: at :: org.apache.commons.fileupload.DefaultFileItem.write(DefaultFileItem.java:442 ) :: :: I am sure it is in the way I implemented the File(File parent, String child) object. As :: below: :: :: File fullFile = new File(item.getName()); :: File currentFile = new File(getServletContext().getRealPath("/"),fullFile.getName()); :: String curFile = currentFile.toString(); :: File diskFile = new File(folder, curFile); // to pass the folder and file to be uploaded :: item.write(diskFile); // This line writes the file to disk. :: :: I think I am declaring currentFile improperly. :: Any ideas? :: :: -----Original Message----- :: From: Schalk [mailto:[EMAIL PROTECTED] :: Sent: Tuesday, March 30, 2004 12:14 PM :: To: 'Jakarta Commons Users List' :: Subject: RE: [File Upload] specifying the directory to upload to :: :: :: Graham :: :: This is the line where you specify the folder: :: You can set the String folder = "folder/to/upload/to/"; at the top of the :: JSP and then use this line: :: :: File diskFile = new File(folder, currentFile); // to pass the folder and :: file to be uploaded :: item.write(diskFile); // This line writes the file to disk. :: :: The setRepositoryPath you were you specify your temp folder. This folder is :: used to temporarily store file data before it is written to disk if :: setSizeThreshold is exceeded. :: :: Kind Regards :: Schalk Neethling :: Web Developer.Designer.Programmer.President :: Volume4.Development.Multimedia.Branding :: emotionalize.conceptualize.visualize.realize :: Tel: +27125468436 :: Fax: +27125468436 :: email:[EMAIL PROTECTED] :: web: www.volume4.com :: :: This message contains information that is considered to be sensitive or :: confidential and may not be forwarded or disclosed to any other party :: without the permission of the sender. If you received this message in error, :: please notify me immediately so that I can correct and delete the original :: email. Thank you. :: :: :: -----Original Message----- :: :: From: Forte, Graham [mailto:[EMAIL PROTECTED] :: :: Sent: Tuesday, March 30, 2004 7:51 PM :: :: To: 'Jakarta Commons Users List' :: :: Subject: [File Upload] specifying the directory to upload to :: :: :: :: 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] :: :: :: :: --------------------------------------------------------------------- :: To unsubscribe, e-mail: [EMAIL PROTECTED] :: For additional commands, e-mail: [EMAIL PROTECTED] :: :: --------------------------------------------------------------------- :: To unsubscribe, e-mail: [EMAIL PROTECTED] :: For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
