in reply to Re^2: Not able to display an image in perl CGI
in thread Not able to display an image in perl CGI

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

Replies are listed 'Best First'.
Re^4: Not able to display an image in perl CGI
by aniammu (Novice) on Apr 29, 2014 at 09:56 UTC
    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

      Try this simple test script

      #!/usr/bin/perl use strict; use CGI ':standard'; use CGI::Carp 'fatalsToBrowser'; my $file = "/cgi-bin/PTF//WP_20140410_19_01_49_Pro.jpg"; print header, start_html('Test'), img({-src=>$file,-alt=>'image'}), end_html;
      Update 1 : Corrected URL (thanks to NetWallah).
      Update 2 : removed ; on first line
      poj
        The file system path will most likely not work - the -src path needs to be either relative to the web server root, or specially configured as a directory in the web server config.

        One possible option is to do:

        my $file = "/cgi-bin/PTF//WP_20140410_19_01_49_Pro.jpg";
        which assumes that "/var/www" is the server root.

                What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
                      -Larry Wall, 1992

      Current code is as below, but still the same error.

      Then look at the other stuff (not the code), the server configuration ... gather version info wherever you can

        Please find below information...
        # /opt/apache-tomcat-7.0.32/bin/version.sh Using CATALINA_BASE: /opt/apache-tomcat-7.0.32 Using CATALINA_HOME: /opt/apache-tomcat-7.0.32 Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.32/temp Using JRE_HOME: /usr Using CLASSPATH: /opt/apache-tomcat-7.0.32/bin/bootstrap.jar:/op +t/apache-tomcat-7.0.32/bin/tomcat-juli.jar Server version: Apache Tomcat/7.0.32 Server built: Oct 3 2012 08:51:20 Server number: 7.0.32.0 OS Name: Linux OS Version: 2.6.32-279.19.1.el6.x86_64 Architecture: amd64 JVM Version: 1.6.0_24-b24 JVM Vendor: Sun Microsystems Inc. #
        Thanks in advance
      More information about this error may be available in the server error log.

      Have you checked the server error log?

        I have been checking /var/log/httpd/error_log. Do we have some other log other than this ?
      just for curiousity.. why you use non parsed header?
      -nph => 1,
      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

        I am not aware of the parser and non parser header. I will go through it now

        just for curiousity.. why you use non parsed header? -nph => 1,

        for the intended effect :D