in reply to Not able to display an image in perl CGI

Do you need to output an HTTP status line?

print "HTTP/0.9 200 OK\r\n"; print "Content-Type: image/jpeg\r\n"; print "\r\n"; ...

Replies are listed 'Best First'.
Re^2: Not able to display an image in perl CGI
by aniammu (Novice) on Apr 29, 2014 at 09:45 UTC
    # cat image1 #!/usr/bin/perl use File::Copy; print "HTTP/0.9 200 OK\r\n"; print "Content-Type: image/jpeg\r\n"; print "\r\n"; copy "/var/www/cgi-bin/PTF//WP_20140410_19_01_49_Pro.jpg", \*STDOUT; #

    After introducing Header information also i am getting the same error..

    [Tue Apr 29 14:52:59 2014] [error] [client 10.142.236.15] malformed he +ader from script. Bad header=\xff\xd8\xff\xe1\xa7\xdcExif: image1
      What webserver? Try
      #!/usr/bin/perl -- use File::Copy; use CGI qw( header ); my $file = "/var/www/cgi-bin/PTF//WP_20140410_19_01_49_Pro.jpg"; print header( -type => q{image/jpeg} , -nph => 1, -Content_length => - +s $file ); copy $file, \*STDOUT;

      FWIW, its looking more and more like your webserver configuration is the problem

        Current code is as below, but still the same error.
        #!/usr/bin/perl -- use File::Copy; use CGI qw( header ); my $file = "/var/www/cgi-bin/PTF//WP_20140410_19_01_49_Pro.jpg"; print header( -type => q{image/jpeg} , -nph => 1, -Content_length => - +s $file ); copy $file, \*STDOUT;
        I tried both in firefox and IE. in the both browsers i am getting the below error..
        Internal Server Error The server encountered an internal error or misconfiguration and was u +nable to complete your request. Please contact the server administrator, root@localhost and inform the +m of the time the error occurred, and anything you might have done th +at may have caused the error. More information about this error may be available in the server error + log. ---------------------------------------------------------------------- +---------- Apache/2.2.15 (Red Hat) Server at 10.58.117.54 Port 80