View | Details | Raw Unified | Return to bug 14321
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-retrieve-file.tt (+6 lines)
Line 0 Link Here
1
[%# This template is called only for a very simple error message %]
2
<html>
3
<body>
4
Your search [% IF hash %]for [% hash %][% END %] was not successful.
5
</body>
6
</html>
(-)a/opac/opac-retrieve-file.pl (-11 / +25 lines)
Lines 19-37 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use CGI;
21
use CGI;
22
use Encode;
22
23
24
use C4::Auth;
23
use C4::Context;
25
use C4::Context;
24
use C4::UploadedFiles;
26
use C4::Output;
27
use Koha::Upload;
25
28
26
my $input = new CGI;
29
my $input = CGI::->new;
30
my $hash = $input->param('id'); # historically called id (used in URLs?)
27
31
28
my $id = $input->param('id');
32
my $upl = Koha::Upload->new({ public => 1 });
29
my $file = C4::UploadedFiles::GetUploadedFile($id);
33
my $rec = $upl->get({ hashvalue => $hash, filehandle => 1 });
30
exit 1 if !$file || !-f $file->{filepath};
34
my $fh = $rec->{fh};
31
35
if( !$rec || !$fh ) {
32
open my $fh, '<', $file->{filepath} or die "Can't open file: $!";
36
    my ( $template, $user, $cookie ) = get_template_and_user({
33
print $input->header( C4::UploadedFiles::httpheaders( $file->{filename} ));
37
        query           => $input,
34
while(<$fh>) {
38
        template_name   => 'opac-retrieve-file.tt',
35
    print $_;
39
        type            => 'opac',
40
        authnotrequired => 1,
41
    });
42
    $template->param( hash => $hash );
43
    output_html_with_http_headers $input, $cookie, $template->output;
44
} else {
45
    my @hdr = $upl->httpheaders( $rec->{name} );
46
    print Encode::encode_utf8( $input->header( @hdr ) );
47
    while( <$fh> ) {
48
        print $_;
49
    }
50
    $fh->close;
36
}
51
}
37
close $fh;
(-)a/tools/upload.pl (-2 / +1 lines)
Lines 89-95 if( $op eq 'new' ) { Link Here
89
        output_html_with_http_headers $input, $cookie, $template->output;
89
        output_html_with_http_headers $input, $cookie, $template->output;
90
    } else {
90
    } else {
91
        my @hdr = $upl->httpheaders( $rec->{name} );
91
        my @hdr = $upl->httpheaders( $rec->{name} );
92
        print $input->header( @hdr );
92
        print Encode::encode_utf8( $input->header( @hdr ) );
93
        while( <$fh> ) {
93
        while( <$fh> ) {
94
            print $_;
94
            print $_;
95
        }
95
        }
96
- 

Return to bug 14321