I was able to upload text, image, exe files, and other binaries with oreily
package.
I am using the nov 20 2000 version

here's the code from my jsp file

private String processRequest
(
  HttpServletRequest request
)
{
  String cType = request.getContentType();

  if (cType != null &&
cType.toLowerCase().startsWith("multipart/form-data")) 
  {
    try
    {
      String appPath = getPath(request);
      MultipartRequest multi = new MultipartRequest(request, appPath);
      String submit = multi.getParameter(SUBMIT_UPLOAD_NAME);
      if(submit != null && (submit.equals(SUBMIT_UPLOAD_VAL)))
      {
        Enumeration files = multi.getFileNames();
        if(!files.hasMoreElements())
        {
          return("No file was uploaded!");
        }
        else
        {
          return("uploaded " +
multi.getFilesystemName((String)files.nextElement()) + " to " + appPath);
        }
      }
    }
    catch(IOException e)
    {
      return(e.getMessage());
    } 
  }
  return("");
}

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 27, 2000 5:37 PM
To: [EMAIL PROTECTED]
Subject: RE: file upload servlet




Thank you, Tim.

I tried this one first before I posted the message. It worked only for text
files.

I tried two versions. The very first and the very last one.

Did you work with this library before? How did you upload binary files?

Yanbin



|--------+-------------------------------->
|        |          Tim Cronin            |
|        |          <[EMAIL PROTECTED]|
|        |          eClub.com>            |
|        |                                |
|        |          12/27/00 06:22 PM     |
|        |          Please respond to     |
|        |          tomcat-user           |
|        |                                |
|--------+-------------------------------->
 
>---------------------------------------------------------------------------
|
  |
|
  |       To:     "'[EMAIL PROTECTED]'"
|
  |       <[EMAIL PROTECTED]>
|
  |       cc:     (bcc: Yanbin Ma/SYS/NYTIMES)
|
  |       Subject:     RE: file upload servlet
|
 
>---------------------------------------------------------------------------
|




they have a good multipart form handler.

http://www.servlets.com/resources/com.oreilly.servlet/

the only draw back is you need to know the path
to store the files at before you parse the multipart request.



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 27, 2000 5:15 PM
To: [EMAIL PROTECTED]
Subject: file upload servlet




Hi all,

Does anybody know a servlet utility that can handle binary file upload?

I appreciate any information you can share.

Ma, Yanbin




Reply via email to