Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 62609 invoked from network); 17 Feb 2003 15:30:45 -0000 Received: from unknown (HELO frankenstein.everyage.com) (62.58.174.90) by daedalus.apache.org with SMTP; 17 Feb 2003 15:30:45 -0000 Received: by frankenstein.everyage.com with Internet Mail Service (5.5.2653.19) id ; Mon, 17 Feb 2003 16:30:32 +0100 Message-ID: From: Nico Krijnen To: "'Jakarta Commons Users List' (E-mail)" Subject: [FileUpload] naming conflicts with existing files Date: Mon, 17 Feb 2003 16:30:32 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, I am using jakarta struts 1.1b in a web application that uses file uploads. Struts is using the commons-fileupload package to handle the multipart form data. My form-bean has two FormFile properties. The Action that handles the upload writes the FormFiles to two files in different directories on the server. When I upload two different files with the same name (= from different directories on the client ofcourse), the resulting files on the server are the same (= content of one of the original files). So only one of my two original files survives. My guess is the multipart handler stores the files in the temp directory with the filename from the client. The second file that is handled has the same name and overwrites the first one. A fix could be to add a number to the filename if it already exists. The following url has an example that handles naming conflicts with existing files http://www.servlets.com/cos (look for FileRenamePolicy). Regards, Nico Krijnen