cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: FileUploadWithAction
Date Fri, 09 Jul 2004 08:19:26 GMT
   Date: 2004-07-09T01:19:26
   Editor: DavidCrossley <crossley@apache.org>
   Wiki: Cocoon Wiki
   Page: FileUploadWithAction
   URL: http://wiki.apache.org/cocoon/FileUploadWithAction

   removed junk attachments

Change Log:

------------------------------------------------------------------------------
@@ -6,59 +6,55 @@
 
 Example of an upload form:
 
-{{{
-<html>
-  <body>
-    <form action="upload" method="post" enctype="multipart/form-data">
-      File:  <input type="file" name="uploadfile" size="50">
-      <input type="submit"/>
-    </form>
-  </body>
-</html>
+{{{
+<html>
+  <body>
+    <form action="upload" method="post" enctype="multipart/form-data">
+      File:  <input type="file" name="uploadfile" size="50">
+      <input type="submit"/>
+    </form>
+  </body>
+</html>
 }}}
 
 Example of an Action to get the uploaded file
 
-{{{
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.cocoon.acting.Action;
-import org.apache.cocoon.environment.Redirector;
-import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.components.request.multipart.FilePart;
-import org.apache.cocoon.components.request.multipart.FilePartFile;
-
-import java.util.Map;
-import java.util.Collections;
-import java.io.File;
-
-public class UploadTest 
-  extends AbstractLogEnabled 
-  implements Action, ThreadSafe
-{
-    public Map act(Redirector redirector, SourceResolver resolver,
-                   Map objectModel, String source, Parameters par)
-        throws Exception
-    {
-        Request request = ObjectModelHelper.getRequest(objectModel);
-        FilePart filePart = (FilePart) request.get("uploaded_file");
-
-        File file = ((FilePartFile)filePart).getFile();
-        getLogger().debug("Uploaded file = " + file.getCanonicalPath());
-        // here you can open an InputStream on the file or whatever
-        // you may also want to delete the file after using it
-        return Collections.EMPTY_MAP;
-    }
-}
+{{{
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.cocoon.acting.Action;
+import org.apache.cocoon.environment.Redirector;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.components.request.multipart.FilePart;
+import org.apache.cocoon.components.request.multipart.FilePartFile;
+
+import java.util.Map;
+import java.util.Collections;
+import java.io.File;
+
+public class UploadTest 
+  extends AbstractLogEnabled 
+  implements Action, ThreadSafe
+{
+    public Map act(Redirector redirector, SourceResolver resolver,
+                   Map objectModel, String source, Parameters par)
+        throws Exception
+    {
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        FilePart filePart = (FilePart) request.get("uploaded_file");
+
+        File file = ((FilePartFile)filePart).getFile();
+        getLogger().debug("Uploaded file = " + file.getCanonicalPath());
+        // here you can open an InputStream on the file or whatever
+        // you may also want to delete the file after using it
+        return Collections.EMPTY_MAP;
+    }
+}
 }}}
 
 For concept and configuration information for file uploads see FileUploadsWithCocoon
-[[BR]]
-[[BR]]
-'''Attachment:''' attachment:20044111544693.jpg [[BR]]
-'''Attachment:''' attachment:resume.rtf [[BR]]
-'''Attachment:''' attachment:Database [[BR]]
-'''Attachment:''' attachment:PageInfo.jsp [[BR]]
+
+'''Attachment:''' attachment:Database

Mime
View raw message