28 |
binmode $fh; |
binmode $fh; |
29 |
my $content = scalar <$fh>; |
my $content = scalar <$fh>; |
30 |
|
|
31 |
|
if ( $filename !~ m/\.(jpg|jpeg|png|gif|tif|tiff)$/i ) { |
32 |
|
$self->result->error("unknown file type $filename"); |
33 |
|
return; |
34 |
|
} |
35 |
|
|
36 |
warn "## $self take_action filename: $filename (", length($content), " bytes)\n"; |
warn "## $self take_action filename: $filename (", length($content), " bytes)\n"; |
37 |
|
|
38 |
$self->argument_value( 'filename' => $filename ); |
$self->argument_value( 'filename' => $filename ); # needed for report_success |
39 |
$self->argument_value( 'content' => $content ); |
$self->argument_value( 'content' => $content ); |
40 |
|
|
41 |
|
my $id = $self->SUPER::take_action( @_ ); |
42 |
|
|
43 |
|
# update database with correct filename (why do I need this?) |
44 |
|
$self->record->set_filename( $filename ); |
45 |
|
|
46 |
|
return $id; |
47 |
|
|
48 |
|
} else { |
49 |
|
$self->result->error("No file uploaded!"); |
50 |
} |
} |
51 |
|
|
|
return $self->SUPER::take_action( @_ ); |
|
52 |
} |
} |
53 |
|
|
54 |
=head2 report_success |
=head2 report_success |