commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Badi <ki...@poonam.org>
Subject Re: [fileupload] - Works in local host and works partially on server.
Date Wed, 26 Feb 2014 20:15:14 GMT
Any comments ?


On Tue, Feb 25, 2014 at 9:25 PM, Kiran Badi <kiran@poonam.org> wrote:

> Hi All,
>
> I need some help, I have below code which works perfectly file in
> localhost and does not work fully when deployed to the linux centos 5.9. If
> I am uploading 6 images, for some reasons it upload 2 or 3 images and
> somehow believe that its overwriting the images, any suggestions as how do
> I fix this.
>
> I have also posted this query to stackexchange,
> and link is http://stackoverflow.com/questions/22029932/apache-
> commons-file-upload-not-uploading-and-renaming-all-files
>
> and also I am on 1.2.2 version of file upload.
>
> http://stackoverflow.com/questions/22029932/apache-
> commons-file-upload-not-uploading-and-renaming-all-files
>
>  } else if (!item.isFormField()) {
>                                        long size = item.getSize();
>                     String contentType = item.getContentType();
>                    System.out.println("Field Name = " + item.getFieldName()
>                             + ", File Name = " + item.getName()
>                             + ", Content type = " + item.getContentType()
>                             + ", File Size = " + item.getSize()
>                             + ", boolean isInMemory = " +
> item.isInMemory());
>                     String fieldname = item.getFieldName();
>                     String name = item.getName();
>                     if ((fieldname.equals("img1")) && name != null) {
>                         if ((size < 1048576) && (("image/jpeg".equals(contentType))
> || ("image/jpg".equals(contentType)) || ("image/gif".equals(contentType))
> || ("image/png".equals(contentType)) || ("image/bmp".equals(contentType))))
> {
>                             String filetype = name.substring(name.
> lastIndexOf("."));
>                             ImageName = System.currentTimeMillis() +
> filetype;
>                             System.out.println(" ImageName1 is " +
> ImageName + "'");
>                             businessfForm.setImg1(ImageName);
>                         } else {
>                             request.setAttribute("ImageError",
> ImageError);
>                         }
>
>                     } else if ((fieldname.equals("img2"))&& name != null){
>                         if ((size < 1048576) && (("image/jpeg".equals(contentType))
> || ("image/jpg".equals(contentType)) || ("image/gif".equals(contentType))
> || ("image/png".equals(contentType)) || ("image/bmp".equals(contentType))))
> {
>                             String filetype = name.substring(name.
> lastIndexOf("."));
>                             ImageName = System.currentTimeMillis() +
> filetype;
>                             System.out.println(" ImageName2 is " +
> ImageName + "'");
>                             businessfForm.setImg2(ImageName);
>                         } else {
>                             request.setAttribute("ImageError",
> ImageError);
>                         }
>                     } else if ((fieldname.equals("img3"))&& name != null) {
>                         if ((size < 1048576) && (("image/jpeg".equals(contentType))
> || ("image/jpg".equals(contentType)) || ("image/gif".equals(contentType))
> || ("image/png".equals(contentType)) || ("image/bmp".equals(contentType))))
> {
>                             String filetype = name.substring(name.
> lastIndexOf("."));
>                             ImageName = System.currentTimeMillis() +
> filetype;
>                             System.out.println(" ImageName3 is " +
> ImageName + "'");
>                             businessfForm.setImg3(ImageName);
>                         } else {
>                             request.setAttribute("ImageError",
> ImageError);
>                         }
>                     } else if ((fieldname.equals("img4"))&& name != null){
>                         if ((size < 1048576) && (("image/jpeg".equals(contentType))
> || ("image/jpg".equals(contentType)) || ("image/gif".equals(contentType))
> || ("image/png".equals(contentType)) || ("image/bmp".equals(contentType))))
> {
>                             String filetype = name.substring(name.
> lastIndexOf("."));
>                             ImageName = System.currentTimeMillis() +
> filetype;
>                             System.out.println(" ImageName4 is " +
> ImageName + "'");
>                             businessfForm.setImg4(ImageName);
>                         } else {
>                             request.setAttribute("ImageError",
> ImageError);
>                         }
>                     }  else if ((fieldname.equals("img5"))&& name != null){
>                         if ((size < 1048576) && (("image/jpeg".equals(contentType))
> || ("image/jpg".equals(contentType)) || ("image/gif".equals(contentType))
> || ("image/png".equals(contentType)) || ("image/bmp".equals(contentType))))
> {
>                             String filetype = name.substring(name.
> lastIndexOf("."));
>                             ImageName = System.currentTimeMillis() +
> filetype;
>                             System.out.println(" ImageName5 is " +
> ImageName + "'");
>                             businessfForm.setImg5(ImageName);
>                         } else {
>                             request.setAttribute("ImageError",
> ImageError);
>                         }
>                     } else if ((fieldname.equals("img6"))&& name != null){
>                         if ((size < 1048576) && (("image/jpeg".equals(contentType))
> || ("image/jpg".equals(contentType)) || ("image/gif".equals(contentType))
> || ("image/png".equals(contentType)) || ("image/bmp".equals(contentType))))
> {
>                             String filetype = name.substring(name.
> lastIndexOf("."));
>                             ImageName = System.currentTimeMillis() +
> filetype;
>                             System.out.println(" ImageName6 is " +
> ImageName + "'");
>                             businessfForm.setImg6(ImageName);
>                         } else {
>                             request.setAttribute("ImageError",
> ImageError);
>                         }
>                     }
>                     File file = new File(destinationDir, ImageName);
>                    try {
>                         item.write(file);
>                     } catch (Exception ex) {
>                         Logger.getLogger(xxx.class.getName()).log(Level.SEVERE,
> "Failed to parse upload request", ex);
>                     }
>                 }
>

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