Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How do I display a jpeg in perl to HTML

by villa (Initiate)
on Dec 14, 2001 at 22:21 UTC ( [id://132016]=perlquestion: print w/replies, xml ) Need Help??

villa has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monks, Can anyone help me show me how do I display a jpeg to my HTML form using the below code. I've tried several ways and no luck displaying a jpeg. I chmod 644 to jpeg and still no luck... In what directory show I locate my jpeg. I've positioned it under the /www and cgi-bin directroys but no luck. Any hints:)
print << "END_OF_REPLY"; Content-type: text/html <HTML> <HEAD> <body bgcolor=\"blue\" text=\"yellow"> <TITLE>THANKYOU!! if no email entered </TITLE> </HEAD> <BR><BR><BR> <H1 ALIGN=CENTER>Thankyou $name !</H1> <BR> <H1 ALIGN=CENTER>Next time....</H1> <BR> <H1 ALIGN=CENTER>Please leave us your email. :-(</H1> <BR> </HTML> END_OF_REPLY }

Replies are listed 'Best First'.
Re: How do I display a jpeg in perl to HTML
by jepri (Parson) on Dec 14, 2001 at 22:34 UTC
    Images are retrieved by your browser as separate documents. You need to place a <img src="http://url.to.jpeg/goes/here.jpg"> in your document and you need to have a webserver serving that picture (you can check by pasting the URL in directly).

    Have a look at how other pages on the net do it.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Re: How do I display a jpeg in perl to HTML
by kwoff (Friar) on Dec 14, 2001 at 23:10 UTC
    One note: don't leave blank space above the 'Content-type' header.

    Another thing: if your CGI scripts are separate from the HTML (usually they are -- say, ScriptAlias of /cgi-bin and DocumentRoot of /usr/local/apache/htdocs), you have to be careful what "base" the image URL is relative to. You might have to put something like

    ... <HEAD> <BASE HREF="http://${hostname}${baseurl}"> ...

      To elaborate on what kwoff said:

      Some web servers are set up to attempt to execute any file located in the cgi-bin directory. In that case, you'll have to put any images under your normal HTML directory, then (as kwoff mentioned) reference them in your script from your document root (or with a full URL).

      Impossible Robot
Re: How do I display a jpeg in perl to HTML
by Zaxo (Archbishop) on Dec 14, 2001 at 22:34 UTC

    No magic. Just print an image tag, it's only html ;-)

    After Compline,
    Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://132016]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-03-28 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found