Josep Riudavets Aguilo wrote:
Hi all...

I'm trying to implement a webpage with an upload file option. I have
visited http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithFlow,
and I have found some info about "FileUploadsWithFlow".

make sure you also read http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithCocoon2.1


and general flow documentation at the wiki.

First step is related to add the uploado option: <html>
<form action="/upload" method="POST" enctype="multipart/form-data">
<input type="file" name="blah"/>
<input type="submit" name="action" value="Upload"/>
</form>
</html>


The second step is:

   <map:match pattern="/upload">
    <map:call function="upload"/>
   </map:match>

But I don't undersand the third step:

var role = Packages.org.mystuff.UploadManager.ROLE;

Warning! This refers to a class named org.mystuff.UploadManager which does not exist. It would be a component deployed in Cocoon which defines a method handle(InputStream is). There is no such component because Cocoon doesn't know what you want to do with the file. When you do part.getInputStream you can do anything with it you like -
save it to a file on disk, to a database, stream it out over the wire to Siberia, etc. The best idea is to put the code for that in a component managed by Cocoon's component manager as depicted in this non-functioning example.


   function upload() {
      var uploader = cocoon.componentManager.getComponent(role);
      var part = cocoon.request.get("blah");
      var success = uploader.handle(part.getInputStream());
      if (success) {
        sendPage("success.html");
      } else {
        sendPage("failure.html");
      }
   }

Where do I have to write this code???

In a flowscript file. Make sure you've read up on flow.


No more things to do? Only these three steps? Do I have to add

<map:flow> into sitemap???

Yes, you do. Can you add that to the wiki?





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



Reply via email to