CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Problem with displaying image

 



zak100
User

Nov 14, 2013, 3:45 AM

Post #1 of 8 (5053 views)
Problem with displaying image Can't Post

Hi,
I am trying to display image , but its not working.

Code
#!C:/Perl64/bin/perl.exe 
print "Content-type: image/gif\n\n";
print <<EOF;
<HTML>
<HEAD>
<TITLE> Coding Page </TITLE>
</Head>
<BODY>
<P>Image uploading

<a href="/cgi-bin/image.cgi?image=create_form.gif">
<a href="/cgi-bin/image.cgi?image=en.gif">
</BODY></HTML>

EOF
exit;


I have tried image sourse tag also.

Code
#!C:/Perl64/bin/perl.exe 





print "Content-type: image/gif\n\n";
print <<HTML;
<html>
<head>
<title> A Simple Perl CGI </title>
</head>
<body>
<img src="en.jpg" width="225" height="225" />
<h1>A Simple Perl CGI </h1>
</body>
HTML
exit;


Can somebody guide me with this problem.

Zulfi.


FishMonger
Veteran / Moderator

Nov 14, 2013, 8:41 AM

Post #2 of 8 (5048 views)
Re: [zak100] Problem with displaying image [In reply to] Can't Post

You're using the wrong Content-Type.

Since you're outputting an html page, you need to use text/html not image/gif.


zak100
User

Nov 14, 2013, 9:14 AM

Post #3 of 8 (5045 views)
Re: [FishMonger] Problem with displaying image [In reply to] Can't Post

Hi,
Thanks for your reply. I used thefollowing code:


Code
#!C:/Perl64/bin/perl.exe 
print "Content-type: text/html\n\n";
print <<EOF;
<HTML>
<HEAD>
<TITLE> Coding Page </TITLE>
</Head>
<BODY>
<P>Image uploading

<a href="/cgi-bin/image.cgi?image=create_form.gif">
<a href="/cgi-bin/image.cgi?image=en.gif">
</BODY></HTML>

EOF
exit;


Its writing image uploading but its not showing any thing.
In the second program, it showing me the image icon which is not the actual image & the text "A Simple Perl CGI"

Code
#!C:/Perl64/bin/perl.exe 

print "Content-type: text/html\n\n";
print <<HTML;
<html>
<head>
<title> A Simple Perl CGI </title>
</head>
<body>
<img src="en.jpg"/>
<h1>A Simple Perl CGI </h1>
</body>
HTML
exit;


Kindly guide me.

Zulfi.


(This post was edited by zak100 on Nov 14, 2013, 9:18 AM)


FishMonger
Veteran / Moderator

Nov 15, 2013, 10:07 AM

Post #4 of 8 (5027 views)
Re: [zak100] Problem with displaying image [In reply to] Can't Post


Quote
In the second program, it showing me the image icon which is not the actual image & the text "A Simple Perl CGI"


Did you check the web server error log?

You'll probably find that it tells you that it couldn't find the image file. You need to make sure you specify the correct path and the image file should not be put in the cgi-bin directory. It should go in/under your html directory.


(This post was edited by FishMonger on Nov 15, 2013, 10:07 AM)


zak100
User

Nov 15, 2013, 10:31 AM

Post #5 of 8 (5022 views)
Re: [zak100] Problem with displaying image [In reply to] Can't Post

Hi,
This is my code:

Code
#!C:/Perl64/bin/perl.exe 

print print "Content-type: text/html\n\n";
print <<HTML;
<html>
<head>
<title> A Simple Perl CGI </title>
</head>
<body>

<img src="en.gif"/>
<h1>A Simple Perl CGI </h1>
</body>
HTML
exit;


I am getting following errors my log files:


Quote
127.0.0.1 - - [15/Nov/2013:23:27:25 +0500] "GET /cgi-bin/en.gif HTTP/1.1" 500 535
[Fri Nov 15 23:27:25 2013] [error] [client 127.0.0.1] (9)Bad file descriptor: don't know how to spawn child process: C:/Apache/cgi-bin/en.gif, referer: http://localhost/cgi-bin/uploadimg3.pl


Can somebody guide me with this error?

Zulfi.


FishMonger
Veteran / Moderator

Nov 15, 2013, 10:41 AM

Post #6 of 8 (5021 views)
Re: [zak100] Problem with displaying image [In reply to] Can't Post

Where is en.gif located?

If it's in your cgi-bin dir, you'll need to move it somewhere else and adjust the path for the src attribute.

Put the en.gif file in the html directory then test this:

Code
#!C:/Perl64/bin/perl.exe  

use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);

print print "Content-type: text/html\n\n";

print <<HTML;
<html>
<head>
<title> A Simple Perl CGI </title>
</head>
<body>

<img src="/en.gif"/>

<h1>A Simple Perl CGI </h1>
</body>
HTML
exit;



zak100
User

Nov 15, 2013, 10:57 AM

Post #7 of 8 (5018 views)
Re: [FishMonger] Problem with displaying image [In reply to] Can't Post

Hi,
Thanks. Its working now. But there is one odd thing. It displays one (1) also before the image.
Thanks for your cooperation.
Zulfi.


zak100
User

Oct 21, 2014, 11:18 AM

Post #8 of 8 (3678 views)
Re: [zak100] Problem with displaying image [In reply to] Can't Post

The URL for running CGI script is:
http://localhost/cgi-bin/uploadimg4.pl

though the image file is in htdocs folder.

Zulfi.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives