commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nico Krijnen <>
Subject [FileUpload] naming conflicts with existing files
Date Mon, 17 Feb 2003 15:30:32 GMT

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

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 (look for FileRenamePolicy).


Nico Krijnen

View raw message