Date: 2004-07-03T23:45:49
   Editor: UpayaVira <[EMAIL PROTECTED]>
   Wiki: Cocoon Wiki
   Page: FileUploadsWithFlow
   URL: http://wiki.apache.org/cocoon/FileUploadsWithFlow

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -1,46 +1,46 @@
 This functionality was introduced in April 4, 2003 and is available in all 2.1 
releases.  See [:FileUploadsWithCocoon2.1] for a general overview of uploading, 
and links to Wiki pages explaining how to upload other than using flow.
 
 Start with the following page:
-{{{
-   <html>
-    <form action="/upload" method="POST" enctype="multipart/form-data">
-     <input type="file" name="upload-file"/>
-     <input type="submit" name="action" value="Upload"/>
-    </form>
-   </html>
+{{{
+   <html>
+    <form action="/upload" method="POST" enctype="multipart/form-data">
+     <input type="file" name="upload-file"/>
+     <input type="submit" name="action" value="Upload"/>
+    </form>
+   </html>
 }}}
 Then hook the /upload URL to a flow function:
-{{{
-   <map:match pattern="/upload">
-    <map:call function="upload"/>
-   </map:match>
-
-   <map:match pattern="/*.html">
-    <map:read src="{1}.html"/>
-   </map:match>
+{{{
+   <map:match pattern="/upload">
+    <map:call function="upload"/>
+   </map:match>
+
+   <map:match pattern="/*.html">
+    <map:read src="{1}.html"/>
+   </map:match>
 }}}
 
 Then write the flow function, let's call it 'upload.js':
-{{{
-   var role = 'org.apache.cocoon.components.upload.FileUploadManager';
-
-   function upload() {
-      var uploader = cocoon.getComponent(role);
-      var part = cocoon.request.get("upload-file");
-      try {
-        uploader.upload (part);
-        cocoon.sendPage("success.html");
-      }catch (Exception) {
-       cocoon.sendPage("failure.html");
-      }
-   }
+{{{
+   var role = 'org.apache.cocoon.components.upload.FileUploadManager';
+
+   function upload() {
+      var uploader = cocoon.getComponent(role);
+      var part = cocoon.request.get("upload-file");
+      try {
+        uploader.upload (part);
+        cocoon.sendPage("success.html");
+      }catch (Exception) {
+       cocoon.sendPage("failure.html");
+      }
+   }
 }}}
 
 ...and register it in the sitemap:
-{{{
-  <map:flow language="javascript">
-    <map:script src="upload.js" />
-  </map:flow>
+{{{
+  <map:flow language="javascript">
+    <map:script src="upload.js" />
+  </map:flow>
 }}}
 
 
@@ -49,26 +49,26 @@
 1) Grab the cocoon-upload.jar file attached to this page (see below), and drop 
it into your WEB-INF/lib directory.
 
 2) Create WEB-INF/user.xroles with these contents:
-{{{
-<?xml version="1.0" encoding="UTF-8"?>
-<role-list>
-        <role name="org.apache.cocoon.components.upload.FileUploadManager"
-                shorthand="upload_manager"
-                
default-class="org.apache.cocoon.components.upload.FileUploadManagerImpl"/>
-</role-list>
+{{{
+<?xml version="1.0" encoding="UTF-8"?>
+<role-list>
+        <role name="org.apache.cocoon.components.upload.FileUploadManager"
+                shorthand="upload_manager"
+                
default-class="org.apache.cocoon.components.upload.FileUploadManagerImpl"/>
+</role-list>
 }}} 
 
 3) Change the <cocoon> element in WEB-INF/cocoon.xconf to read:
-{{{
-<cocoon version="2.1" user-roles="/WEB-INF/user.xroles">
+{{{
+<cocoon version="2.1" user-roles="/WEB-INF/user.xroles">
 }}}
 
 4) ...and add this to your cocoon.xconf:
 
-{{{
-<upload_manager>
-    <uploadfolder>/some/where</uploadfolder>
-</upload_manager>
+{{{
+<upload_manager>
+    <uploadfolder>/some/where</uploadfolder>
+</upload_manager>
 }}}
 
 5) Set the '''enable-uploads''' parameter in WEB-INF/web.xml to '''true''' 
(this is already done for you if you built Cocoon with 
'cocoon.enable-uploads=true' in build.properties or local.build.properties).
@@ -83,5 +83,4 @@
 [[BR]]
 [[BR]]
 '''Attachment:''' attachment:cocoon-upload.jar [[BR]]
-'''Attachment:''' attachment:messageboard.jsp [[BR]]
-'''Attachment:''' attachment:catalog2.jsp [[BR]]
+

Reply via email to