update Cookbook
Christian Hansen [Mon, 11 Apr 2005 06:58:43 +0000 (06:58 +0000)]
MANIFEST
lib/Catalyst/Manual/Cookbook.pod

index 667936f..9e3c12d 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -32,16 +32,16 @@ script/catalyst.pl
 t/01use.t
 t/02pod.t
 t/03podcoverage.t
-t/controller/action/absolute.t
-t/controller/action/begin.t
-t/controller/action/default.t
-t/controller/action/end.t
-t/controller/action/forward.t
-t/controller/action/inheritance.t
-t/controller/action/path.t
-t/controller/action/private.t
-t/controller/action/regexp.t
-t/controller/action/relative.t
+t/component/controller/action/absolute.t
+t/component/controller/action/begin.t
+t/component/controller/action/default.t
+t/component/controller/action/end.t
+t/component/controller/action/forward.t
+t/component/controller/action/inheritance.t
+t/component/controller/action/path.t
+t/component/controller/action/private.t
+t/component/controller/action/regexp.t
+t/component/controller/action/relative.t
 t/engine/request/cookies.t
 t/engine/request/headers.t
 t/engine/request/parameters.t
index 2c126d1..7f4a2db 100644 (file)
@@ -87,19 +87,25 @@ Catalyst Controller module 'upload' action:
 
     sub upload : Global {
         my ($self, $c) = @_;
-        if ($c->req->parameters->{form_submit} eq 'yes') {
-            my $upload = $c->req->upload('my_file');
-            if ($upload->filename) {
+
+        if ( $c->request->parameters->{form_submit} eq 'yes' ) {
+
+            if ( my $upload = $c->request->upload('my_file') ) {
+
                 my $filename = $upload->filename;
-                my $fh = $upload->fh;
-                open(NEW_FILE, ">/tmp/upload/$filename") or die
-                    "Can't open file for writing: $!";
-                while ($fh->read(my $buf, 32768)) {
+                my $fh       = $upload->fh;
+
+                open( NEW_FILE, ">/tmp/upload/$filename" ) 
+                  or die( "Can't open file for writing: $!" );
+
+                while ( $fh->read( my $buf, 32768 ) ) {
                     print NEW_FILE $buf;
                 }
+
                 close(NEW_FILE);
             }
         }
+        
         $c->stash->{template} = 'file_upload.html';
     }
 
@@ -122,21 +128,26 @@ Controller:
 
     sub upload : Local {
         my ($self, $c) = @_;
-        if ($c->req->parameters->{form_submit} eq 'yes') {
-            for my $field ($c->req->upload) {
-                my $upload = $c->req->upload($field);
-                if ($upload->filename) {
-                    my $filename = $upload->filename;
-                    my $fh = $upload->fh;
-                    open(NEW_FILE, ">/tmp/upload/$filename") or die
-                        "Can't open file for writing: $!";
-                    while ($fh->read(my $buf, 32768)) {
-                        print NEW_FILE $buf;
-                    }
-                    close(NEW_FILE);
+
+        if ( $c->request->parameters->{form_submit} eq 'yes' ) {
+
+            for my $field ( $c->req->upload ) {
+
+                my $upload   = $c->request->upload($field);
+                my $filename = $upload->filename;
+                my $fh       = $upload->fh;
+
+                open( NEW_FILE, ">/tmp/upload/$filename" ) 
+                  or die ("Can't open file for writing: $!");
+
+                while ( $fh->read( my $buf, 32768 ) ) {
+                    print NEW_FILE $buf;
                 }
+
+                close(NEW_FILE);
             }
         }
+
         $c->stash->{template} = 'file_upload.html';
     }