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
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';
}
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';
}