From b626a8bb9afb11b3eca3091298714541a74e4c15 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Wed, 26 Mar 2008 10:32:51 -0400 Subject: [PATCH] Adding file size limit to picture-upload.pl Signed-off-by: Joshua Ferraro --- .../prog/en/modules/tools/picture-upload.tmpl | 1 + tools/picture-upload.pl | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tmpl index 92e478c904..11f781bedc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tmpl @@ -51,6 +51,7 @@ this patron does not exist in the database. the image format is unrecognized. Koha was unable to open the image for reading. + the image file is too big. the is missing. of an unknown error. Please refer to the error log for more details. diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl index 144ca78e7f..9d212ef1f1 100755 --- a/tools/picture-upload.pl +++ b/tools/picture-upload.pl @@ -220,7 +220,15 @@ sub handle_file { } else { $filename = $1 if ($source =~ /\/([^\/]+)$/); } - warn "\$filename=$filename"; + warn "$filename is " . length($imgfile) . " bytes"; + if (length($imgfile) > 100000) { + warn "$filename is TOO BIG!!! I refuse to beleagur my database with that much data. Try reducing the pixel dimensions and I\'ll reconsider."; + $filerrors{'OVRSIZ'} = 1; + push my @filerrors, \%filerrors; + push @{ $count{filenames} }, { filerrors => \@filerrors, source => $filename, cardnumber => $cardnumber }; + $template->param( ERRORS => 1 ); + return %count; + } my $mimetype = $mimemap->{lc ($1)} if $filename =~ m/\.([^.]+)$/i; warn "$filename is mimetype \"$mimetype\"" if $DEBUG; my $dberror = PutPatronImage($cardnumber,$mimetype, $imgfile) if $mimetype; -- 2.39.5