commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Omar Adobati <omar.adob...@gmail.com>
Subject [File Upload] Error 404
Date Sun, 02 Jan 2005 15:10:26 GMT
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
omar.adobati@gmail.it

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message