portals-pluto-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "nik gonzalez" <ngonza...@gluecode.com>
Subject File upload using commons fileuploader not working
Date Fri, 04 Feb 2005 23:12:34 GMT
Hello,

I ran the following code in my portlet.

	        PortletFileUpload dfu = new PortletFileUpload();
            //get the FileItems
            List fileItems = dfu.parseRequest(request);
            Iterator iter = fileItems.iterator();
            while (iter.hasNext())
            {
                FileItem item = (FileItem) iter.next();
                if (item.isFormField())
                {
                    //pass along to render request
                    String fieldName = item.getFieldName();
                    String value = item.getString();
                    response.setRenderParameter(fieldName, value);
                }
                else
                {
                    //write the uploaded file to a new location
                    String fieldName = item.getFieldName();
                    String fileName = item.getName();
                    String contentType = item.getContentType();
                    long size = item.getSize();
                    response.setRenderParameter("size",
Long.toString(size));
                    response.setRenderParameter("contentType", contentType);
                    String tempDir = System.getProperty("java.io.tmpdir");
                    System.out.println("tempDir: "+tempDir);
                    String serverFileName = fieldName + "-portlet.tmp";
                    File serverFile = new File(tempDir, serverFileName);
                    item.write(serverFile);
                    response.setRenderParameter("serverFileName",
                        serverFileName);
                    getPortletContext().log(
                        "serverFileName : " + tempDir + "/" +
serverFileName);
                }
            }

Once i submit the multipart form, it does not enter the while loop meaning
that the iterator is empty.  Is this a bug in Pluto?

I attached the rest of the source code. got this from one of the messages in
this mailing list.

Thanks,
Nik





--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.5 - Release Date: 2/3/2005


Mime
View raw message