|
Lines 1-77
Link Here
|
| 1 |
#!/usr/bin/perl |
|
|
| 2 |
|
| 3 |
|
| 4 |
# script to upload a picture to a borrowerimages directory. |
| 5 |
# checks to see if its either displaying the upload form |
| 6 |
# or doing the actual upload. |
| 7 |
# written by Waylon Robertson (genjimoto@sourceforge) 2005/08/22 |
| 8 |
|
| 9 |
|
| 10 |
# Copyright 2000-2002 Katipo Communications |
| 11 |
# |
| 12 |
# This file is part of Koha. |
| 13 |
# |
| 14 |
# Koha is free software; you can redistribute it and/or modify it under the |
| 15 |
# terms of the GNU General Public License as published by the Free Software |
| 16 |
# Foundation; either version 2 of the License, or (at your option) any later |
| 17 |
# version. |
| 18 |
# |
| 19 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
| 20 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
| 21 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 22 |
# |
| 23 |
# You should have received a copy of the GNU General Public License along |
| 24 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 25 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 26 |
|
| 27 |
use strict; |
| 28 |
use warnings; |
| 29 |
|
| 30 |
use C4::Auth; |
| 31 |
use C4::Context; |
| 32 |
use C4::Output; |
| 33 |
use CGI; |
| 34 |
|
| 35 |
|
| 36 |
my $input = new CGI; |
| 37 |
my $name = $input->param('name'); |
| 38 |
my $borrowernumber = $input->param('borrowernumber'); |
| 39 |
my $photo = $input->param('photo'); |
| 40 |
|
| 41 |
my $template_name; |
| 42 |
my $htdocs = C4::Context->config('intrahtdocs'); |
| 43 |
my $upload_dir = $htdocs."/borrowerimages"; |
| 44 |
if($photo eq ""){ |
| 45 |
$template_name = "members/member-picupload.tmpl"; |
| 46 |
} else { |
| 47 |
$template_name = "members/moremember.tmpl"; |
| 48 |
} |
| 49 |
|
| 50 |
my ($template, $loggedinuser, $cookie) |
| 51 |
= get_template_and_user({template_name => $template_name, |
| 52 |
query => $input, |
| 53 |
type => "intranet", |
| 54 |
authnotrequired => 0, |
| 55 |
flagsrequired => {borrowers => 1}, |
| 56 |
debug => 1, |
| 57 |
}); |
| 58 |
if ($photo){ |
| 59 |
|
| 60 |
my $filename=$borrowernumber.'.jpg'; |
| 61 |
my $upload_filehandle = $input->upload("photo"); |
| 62 |
open (my $upload_fh, '>', "$upload_dir/$filename"); |
| 63 |
binmode $upload_fh; |
| 64 |
while ( <$upload_filehandle> ) |
| 65 |
{ |
| 66 |
print $upload_fh; |
| 67 |
} |
| 68 |
close $upload_fh; |
| 69 |
} |
| 70 |
else { |
| 71 |
$template->param( |
| 72 |
borrowernumber => $borrowernumber, |
| 73 |
name => $name |
| 74 |
); |
| 75 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 76 |
} |
| 77 |
print $input->redirect("http://intranet/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber"); |
| 78 |
- |