commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ip, Ting Shing" <>
Subject commons-file upload
Date Wed, 05 Mar 2003 17:08:57 GMT
I have the follwing code with upload one file  to "d:\\test\\testfile".
After the upload, i have opened  the file "d:\\test\\testfile". it was
totally not the original file. It contains a string "upload". WHat is wrong
with mijn code.
  public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();
      try {
      ControllerResponse res = (ControllerResponse) request.getAttribute(
      FileUpload fu = new FileUpload();
      // maximum size before a FileUploadException will be thrown
      // maximum size that will be stored in memory
      // the location for saving data that is larger than getSizeThreshold()
      List fileItems = fu.parseRequest(request);
      // assume we know there are two files. The first file is a small
      // text file, the second is unknown and is written to a file on
      // the server
      Iterator i = fileItems.iterator();

      FileItem fi;
      String fileName;
      File file;
      // write the file
      out.println("<p>The servlet has received a POST. This is the
        fi = (FileItem);
        fileName = fi.getName();
        //file = new File(fileName);
        out.println("<p>Uploading file:  " + fileName +"<p>");
      out.println("<p>The servlet has received a POST. This is the
    } catch(DBException dbe) {
      throw new ServletException("Tempory directory has not been defined in
the SETUP table", dbe);
    } catch (Exception fue) {
      throw new ServletException( fue);
- - - - - - - - DISCLAIMER - - - - - - - - 
Unless indicated otherwise, the information contained in this message is
privileged and confidential, and is intended only for the use of the
addressee(s) named above and others who have been specifically authorized to
receive it. If you are not the intended recipient, you are hereby notified
that any dissemination, distribution or copying of this message and/or
attachments is strictly prohibited. The company accepts no liability for any
damage caused by any virus transmitted by this email. Furthermore, the
company does not warrant a proper and complete transmission of this
information, nor does it accept liability for any delays. If you have
received this message in error, please contact the sender and delete the
message. Thank you.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message