Spike,

I just did what you are trying to do.   Here's the
HTML:

<FORM
action='http://<%=host%>:<%=port%>/jetspeed/portal?action=SWFileMoverAction'
METHOD='POST' ENCTYPE='multipart/form-data'
name='browse_form'>
    <BR>
    Choose a file to upload.
    <BR><BR>
    <INPUT TYPE=FILE NAME=file1>
    <BR><INPUT type='submit' name='submit'
value='Submit'>
</FORM>


Here's the action that I created, SWFileMoverAction:

package org.apache.jetspeed.modules.actions;

import org.apache.turbine.modules.actions.*;
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.Log;
import org.apache.turbine.modules.Action;
import com.sw.jetspeed.*;
import javax.servlet.http.*;
import java.io.IOException;
import com.oreilly.servlet.MultipartRequest;


/*
 * This method is the action for the FileMover
portlet.
 */
 public class SWFileMoverAction extends Action
{

        private String parent = "";

    public void doPerform(RunData data) throws
Exception
    {
            HttpServletRequest request = data.getRequest();


            //begin
                try {
                      MultipartRequest multi =
                        new MultipartRequest(request,
"C:\\jakarta-tomcat-3.3-m4\\webapps\\test\\Marketing",
10*1024*1024); // 10MB

                    }
                    catch (IOException lEx) {
                      Log.error(lEx + "error reading or saving
file");
    }
}




The form is submitted to the action SWFileMoverAction.
 The action creates a MultipartRequest which takes the
arguments: request, location to upload file, and the
file size maximum.

HTH,





--- Spike Hains <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I am trying to write a jsp portlet that will allow
> jetspeed users to upload
> files and would like to know how to I access the
> file element of a
> multi-part form submission from a jsp portlet?
> 
> On submission, I'm doing this in the jsp portlet
> page: 
> 
> <%
> ...
> RunData data =
>
(RunData)pageContext.getAttributeJspService.RUNDATA,PageContext.REQUEST_SCOP
> E);
> FileItem myfile =
> data.getParameters().getFileItem("uploadfilename");
> ...
> %>
> 
> I check 'data' before I try and get the fileitem but
> it is null. Should this
> work? Is there a more appropriate way to handle file
> uploading in jsp
> portlets?
> 
> Originally I was going to use O'Reilly's multipart
> form classes and was able
> to upload files in a jsp page OUTSIDE of the
> jetspeed application directory.
> When I would put the same jsp file in a portlet, the
> request object seemed
> empty.
> 
> Any input, suggestions or direction is appreciated.
> 
> Thanks all,
> 
> ~spike
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/

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

Reply via email to