By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

How to display the JPEG image using PERL with HTML?

100+
P: 147
Hi,

I am running Apache and the Active Perl. In Apache, CGI folder, i had one JPEG image. I wants to display this JPEG image in my browser as the header.

Expand|Select|Wrap|Line Numbers
  1. use CGI qw(:all);
  2. print "Content-type: text/html\n\n";
  3. print "<body bgcolor="FFFF">;
  4. print "<img src=\cgi-bin\header.jpg>";
  5. print "</body>;
  6. print "</html>;
  7.  
when i run this program, i can't able to see the image, its just showing small cross icon. My image path is correct.Showing background color. I don't know, whats a problem.



Thanks in Advance
Feb 8 '11 #1
Share this Question
Share on Google+
2 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Try taking the images out of the cgi-bin folder. That should be reserved specifically for cgi scripts. In your web root for the site, create an images or pics folder and reference that instead and see if it works.

This isn't so much a Perl issue as it is an HTML path to image issue.

Also, considering you have over 100 posts, this is your only warning.... Please use CODE TAGS around code you post in the forums!
Feb 8 '11 #2

miller
Expert 100+
P: 1,089
Your problem is in this line:
Expand|Select|Wrap|Line Numbers
  1. print "<img src=\cgi-bin\header.jpg>";
That will become <img src=i-binheader.jpg> because you aren't escaping your backslashes. However, since this is html, you probably want forward slashes anyway.
Expand|Select|Wrap|Line Numbers
  1. print "<img src=/cgi-bin/header.jpg>";
- Miller
Feb 8 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.