Hi there!

I am trying to upload a zip file and save it somewhere on the hard-drive.
I am using cocoon 2.1.4. Can anybody suggest me what is the best way to upload files in cocoon2.1.4 version.
I am doing as shown below and I am not able to pick up the file. Don't know where I am going wrong. Any suggestions or tips on this
matter would be of great help to me. Thanks in advance.

In xsl:
--------------------
<form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="uploadedFile"/>
        <br/>
        <input name="submit" type="submit"/>
</form>


In sitemap:
--------------------------------
actions:
      <map:action name="fileupload" src="">
pipeline:
  <map:match pattern="upload">
        <map:act type="fileupload">     
                <map:parameter name="uploadedFile" value="{request-param:uploadedFile}"/>
                <map:serialize type="xhtml"/>
        </map:act>
    </map:match>


My java class file:
--------------------------------
public class UploadPackage extends AbstractLogEnabled implements Action
{

public Map act(Redirector redirector,
   SourceResolver resolver,
   Map objectModel,
   String src,
   Parameters parameters)
throws Exception {

Request request = ObjectModelHelper.getRequest(objectModel);

Part filePart = (PartOnDisk) request.get(
"uploadedFile");

if (filePart != null) {

getLogger().debug(
"Uploaded file name = " + filePart.getFileName());

}
else {

getLogger().debug(
"File not found");

}

return java.util.Collections.EMPTY_MAP;

}

}

Reply via email to