dear all,

i'm trying to upload a file from a jsr168 portlet. but i'm unable to save the 
uploaded file.

the jsp in which i upload the file is below

--------------------------------------------------------------------------------


........
........
<%@ page 
import="com.srilogic.portal.portlets.jsr168.example.PersonalizationPortlet" %>


<%
RenderRequest pReq = 
(RenderRequest)request.getAttribute("javax.portlet.request");
RenderResponse rRes = 
(RenderResponse)request.getAttribute("javax.portlet.response");
PortletPreferences pref = pReq.getPreferences();
PortletURL actionURL = rRes.createActionURL();
%>


<FORM METHOD="POST" ACTION="<%=actionURL.toString()%>" 
ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="myFile" ID="myFile">
<INPUT TYPE="SUBMIT" NAME="<%=PersonalizationPortlet.CHANGE_IMAGE%>" 
VALUE="changeImage">
</FORM>


--------------------------------------------------------------------------------


this is the way i tryied to get the uploaded file from the portlet class. the 
below is the relavent part of my "PersonalizationPortlet.java"

 public void processAction(
  ActionRequest request,
  ActionResponse actionResponse)
  throws PortletException, IOException {

   //lets try to write the file some where

   InputStream in = request.getPortletInputStream();
   OutputStream os = new FileOutputStream("c:\\demo.out");

      int i = in.read();
   while (i != -1) {
      os.write(i);
      i = in.read();
   }
    os.close();
    in.close();

     }
   }
 }

--------------------------------------------------------------------------------

this will save a emply file to c:\demo.out what ever file i uplod from the jsp.

any help please


kind regards
-thiwanka




Reply via email to