I need an help using File Upload utility.

I use the code below to put any images in a web server. The images are
rightly uploaded on the server but the browser show me a 404 error
code... then if I refresh the page I can see the page in the right
way. Any ideas? (the code is in the jsp page)

<%

  [...some code to set parameters...]

  boolean isMultipart = FileUpload.isMultipartContent(request);

  if(isMultipart){
    DiskFileUpload upload = new DiskFileUpload();

    List item = upload.parseRequest(request);

    Iterator iter  = item.iterator();
    while(iter.hasNext()){
      FileItem fitem = (FileItem)iter.next();           
      if(fitem.isFormField()){
        if(fitem.getFieldName().equals("galleryName")){
         gallery = fitem.getString();
         out.println("Gallery " + gallery + "<br>");
         File d = new File(upDir+gallery+"/");
         if(d.exists() && d.isDirectory()){
           out.println(d.getCanonicalPath() + " esiste gia");
         }else{
           d.mkdir();
           out.println(d.getCanonicalPath() + " creata");
         }
        }
      }else if(!fitem.isFormField()){
        out.println(fitem.getName());
        String[] f = fitem.getName().split("/");
        String fileonly = "";
        if(null != fitem.getName() ){
          int idx = fitem.getName().lastIndexOf("\\");
          if(idx != -1){
            fileonly = fitem.getName().substring(idx+1, 
fitem.getName().length());
          }
        }
        File fn = new File(upDir + gallery + "/" + fileonly);
        fitem.write(fn);
              }
            }
          }

%>

-- 
Adobati Omar
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to