Check out the O'Reilly Servlets book. It has some sample code to do this.
I've included the file (which I've edited a little and corrected one
significant bug). Also included is some sample code for how to use the
class. It only looks for one file, but it could handle more.
try {
String directory =
Configuration.getProperty("yourcompany.import.directory");
MultipartRequest multi = new MultipartRequest(request, directory,
iSubscriberID, iUserID);
// We only allow one file.
Enumeration files = multi.getFileNames();
if(files.hasMoreElements()) {
String name = (String) files.nextElement();
filename = multi.getFilesystemName(name);
if(multi.getFile(name).length() == 0) throw new ZeroLengthFileException();
}
}
-----Original Message-----
From: Aimn [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 05, 2000 12:55 PM
To: [EMAIL PROTECTED]
Subject: uploading files
Hi everyone
Could someone direct me on how to upload text files and images in JSP.
Thanks in advance.
MultipartRequest.java