Hi Peter, You could also use the Commons FileUpload package of the Jakarta project: http://jakarta.apache.org/commons/fileupload/index.html
I personally have used the cos.jar package of Jason Hunter as well and it has served its purpose fine so far. Johannes joe <[EMAIL PROTECTED]> 05.04.2003 22:16 Please respond to "Tomcat Users List" <[EMAIL PROTECTED]> To Tomcat Users List <[EMAIL PROTECTED]> cc Subject Re: upload and renameto apache-tomcat problem hi! i'm using the oreilly cos multipart package. it's working perfectly and you have the source. see for yourself: http://www.servlets.com/cos/index.html joe Peter H. wrote: > Hello Tomcat-Community, > > I try to figure out a strange but reproduceable error: > Using Apache and Tomcat under windows and maybe linux. > > After uploading a file to a temporary dir and renaming (moving) it > to a apache accessible folder i have strange problems... > > If i upload a image with the attached servlet and after it accessing > the image with apache i must wait some seconds to get a succesful > renameTo. the problem is that if i don't create the temporary image > file with java the renameTo always succeeds. but the servlet should > have file upload behaviour... > > maybe its the FileServletWrapper but uploading multiple times without > accessing the image with apache there is no problem! > > ps. The FileServletWrapper is only available as class code... > Any Suggestions? > > Thanks > Peter > > > <code> > import java.io.*; > import javax.servlet.*; > import javax.servlet.http.*; > import java.util.*; > > public final class FileServlet > extends HttpServlet { > > static public final String TARGET = > "/export/wwwdoc/test.jpg"; > > public void service(HttpServletRequest req, HttpServletResponse resp) > throws IOException { > FileServletWrapper request = new FileServletWrapper(req, > new File("/temp")); > File source = null; > > if(request.getFileParameter("file") != null) { > source = request.ucdGetFileParameter("file").getFile(); > } > PrintWriter writer = resp.getWriter(); > writer.write("<HTML>"); > writer.write("<BODY>"); > writer.write("<FORM NAME=\"main\" > ACTION=\"http://127.0.0.1/fileservlet\" METHOD=\"post\" > ENCTYPE=\"multipart/form-data\">"); > writer.write("<INPUT TYPE=\"file\" NAME=\"file\"/>"); > writer.write("<INPUT TYPE=\"submit\" VALUE=\"upload\"/>"); > writer.write("<hr>"); > if(source != null) { > File target = new File(TARGET); > if(target.exists()) { > writer.write("Target file exists<br>"); > if(!target.delete()) { > writer.write("Target file delete failed:" + target + "<br>"); > return; > } > } > if(source.renameTo(target)) { > writer.write("rename succeeded<br>"); > } > else { > writer.write("rename failed<br>"); > } > } > writer.write("</FORM>"); > writer.write("</BODY>"); > writer.write("</HTML>"); > } > } > </code> > > > > _________________________________________________________________ > Mit dem MSN Messenger eine Reise für 4 Personen nach Barcelona > gewinnen jetzt mitmachen! > http://www.sweepstakes2003.com/entry.aspx?locationid=15 > > > --------------------------------------------------------------------- > 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]