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