DieVers
DieVers

Reputation: 49

Simple CGI/Perl Script not displaying background image

#!/usr/local/bin/perl
use warnings;
use strict;

use CGI qw(:standard);
print header;
print start_html(-title=>"Hello World", 
-bgcolor=>"#cccccc", -text=>"#999999",
-background=>"healo.jpg");

The color displays, but not the image. I have the healo.jpg located in the bin folder and my home folder. I took this code from http://www.cgi101.com/book/ch1/text.html Please help.

Upvotes: 0

Views: 1640

Answers (2)

nandhp
nandhp

Reputation: 4817

If your CGI script is in a standard cgi-bin, the file healo.jpg cannot be stored there because it is not a CGI script. Try putting it somewhere else.

For example, you could put the image file in your wwwroot, so that you can find it at http://csvlife.com/healo.jpg (there's already something there), and then change that part of the code to -background=>"/healo.jpg".

Upvotes: 1

ernie
ernie

Reputation: 6356

Examine your generated HTML. That's going to generate a background attribute of the form:

background = 'healo.jpg'

This means healo.jpg needs to be in the same directory as wherever you currently are, which is likely not the same as your home folder.

You'll either need to copy the image to the webroot (which you likely can't do), or change the argument to start_html to be an absolute path, e.g. background ='/healo.jpg'

Upvotes: 0

Related Questions