Hi, it used somehow the common.fileupload 1.0, but now I have put the 1.2 jar 
directly with the code in stead of in tomcat/commons/lib directory and it works 
better (recognizes the isMultiPartForm).
 
But now List /* FileItem */ items = upload.parseRequest(aReq); goes wrong.
I tried using FileItemFactory, DiskFileItemFactory, PortletFileUpload(factory) 
with and without factory and List<FileItem> items, List items.
 
The tomcat log only shows: 
[org.apache.ojb.broker.core.PersistenceBrokerImpl] WARN: No running tx found, 
please only store in context of an PB-transaction, to avoid side-effects - e.g. 
when rollback of complex objects
But I am not sure if it is related to the problem.
 
Please help!!!!
 
import java.io.*;
import java.util.Iterator;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.portlet.PortletFileUpload;
 
...........
 
       public void processAction(ActionRequest aReq, ActionResponse aRes)throws 
PortletException, IOException {
 
         DiskFileItemFactory factory = new DiskFileItemFactory();
         PortletFileUpload upload = new PortletFileUpload(factory);
         boolean isMultiPart = upload.isMultipartContent(aReq);              
         if (isMultiPart){
            try {
                List /* FileItem */ items = upload.parseRequest(aReq);
                ...................

________________________________

Van: Patrick Duin [mailto:[EMAIL PROTECTED]
Verzonden: do 22-3-2007 17:27
Aan: Jetspeed Users List
Onderwerp: RE: jetspeed with file upload - multipart



Hi Erik,
We are using:
        FileItemFactory factory = new DiskFileItemFactory();
        PortletFileUpload upload = new PortletFileUpload(factory);
        items = upload.parseRequest(request);

So PortletFileUpload instead of your DiskFileUpload, maybe it helps.

Cheers,
        Patrick.


>
> I think your error is in the ENCRYPT attribute, this
> attribute doesn't exist in the FORM element
> (http://www.w3.org/TR/html401/interact/forms.html). You must
> use the attribute ENCTYPE. For example:
>
> <form method='post' name='fileForm' action='<portlet:actionURL />'
> enctype='multipart/form-data'>
>
> > I am trying to upload a jpg form a form.
> > But when I run it it does not give an error, but I know it
> does not go
> further then when I do something with the request. (check if
> it is multipart, and when I delete this it holds at putting
> it in items)
> > I am busy with this for more than 2 day so please help <form
> > method="POST" ENCRYPT="multipart/form-data"
> action="<portlet:actionURL />" >
> >  <input type="file" name="photo">
> >  <input type="SUBMIT" name="button" value="upload"> </form>
> >
> > import org.apache.commons.fileupload.portlet.PortletFileUpload;
> > import org.apache.commons.fileupload.*;
> >
> > import javax.portlet.*;
> >
> > public void processAction(ActionRequest request, ActionResponse
> response) throws PortletException, IOException {
> >  boolean isMultiPart =
> PortletFileUpload.isMultipartContent(request);
> >  if (isMultiPart){
> >   DiskFileUpload diskUpload = new DiskFileUpload();
> >
> >      List items = null;
> >      items = upload.parseRequest(request);
> >
> >      Iterator itr = items.iterator();
> >      while (itr.hasNext()) {
> >       FileItem item = (FileItem) itr.next();
> >       if (item.isFormField()) {
> >       } else {
> >        String itemName = item.getName();
> >        File savedFile = new
> File(request.getPortletSession().getPortletContext().getRealPa
> th("/")+"u
> ploadedFiles/"+itemName);
> >        item.write(savedFile);
> >       }
> >      }  
> >  }
> > }
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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




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

Reply via email to