venkat,
here is the one way to use it:
MultipartRequest multi =
new MultipartRequest(request, dirName, 100*1024*1024,
"ISO-8859-1", new DefaultFileRenamePolicy());
Enumeration files = multi.getFileNames();
while (files.hasMoreElements()) {
String name = (String)files.nextElement();
File f = multi.getFile(name);
// process your file if needed
}
The file name will work as follows:
client server
myfile.txt ----> myfile.txt if no file myfile.txt exist
myfile.txt ----> myfile1.txt if file myfile.txt exist
myfile.txt ----> myfile2.txt if file myfile.txt and myfile1.txt exist
Hope this help.
John
-----Original Message-----
From: Venkat [mailto:[EMAIL PROTECTED]
Sent: Monday, March 10, 2003 12:40 AM
To: Tomcat
Subject: file renaming using Multipart class.
Hi all,
Sorry for posting a jsp related qury rather tomcat one.But i need it badly
and i have to finish it with in one hr.I tried jsp interest.Hope some one
helps me here.
I am tying to upload a file from jsp page using bean MultiPartRequest class
that come with oreilly examples.
I am using the constructor which takes three parameters 1.request 2. dir 3.
file size
Itz working and it is storing in the dir given by me.
But the file name is default file name which i selected from the browser.
Here the problem is if different users sends the file with same name it is
replacing the old file.
So i want to upload the file selected by the user with the name specifed by
me.
How to do this?
I checked the MultiPartClass constructors it has another constructor wich
take as FileRenamePolicy interface but i didn't understand this. and how to
create this interface using file as parameter?
Can some one help me out how to do this?
Thanks in advance
venkat
---------------------------------------------------------------------
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]