Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Broken Images....I don't understand

by rawjoeshaw (Sexton)
on Aug 28, 2004 at 16:51 UTC ( [id://386616]=perlquestion: print w/replies, xml ) Need Help??

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

Hi monks, I'm diving into perl cgi and I can't figure out why my script doesn't display images, rather broken links when executed. The script is:
#!/usr/bin/perl -w $imagePath = "http://my.domain/images/header_glow.jpg"; print "Content-type: text/html\n\n"; print <<ENDHTML; <html> <head> <title>A Page</title> </head> <body background=$imagePath> <h3>HELLO</H3> <img src=$imagePath> </body> </html> ENDHTML
I tried using different paths to my image, absolute, relative, but none show. However, if I right click on the broken image and say view image, it takes me right to it. That's what frustrates me more. Thanks, Joe

*******

I have since solved my problem. My domain provider, mydomain.com, uses one big frame to redirect people. So you get a frame on their server that that has a frame source to my actual computer, http://pcp04397155pcs.nrockv01.md.comcast.net. So therefore, anything with my domain in it is going to show up as a frame with what I actually needed, not the image itself.

Thanks to all your monks for your advice!

Replies are listed 'Best First'.
Re: Broken Images....I don't understand
by traxlog (Scribe) on Aug 28, 2004 at 18:03 UTC
    Works fine here. Tested on Mac with Safari, Explorer and Icab.
    Which browser are you using? Did you try a different one?
    I've had strange problems with Netscape and cgi content every now and again...

    traxlog

    see it here
      I've tested on IE, Netscape, and FireFox. All the same. I see your's works, so I don't get why mine doesn't. You can see it here. If you want to review the source code, note that my site is contained within one big frame, so you will have to look at the source code for that frame. Could it be a configuration setting in apache? That doesn't make sense to me though.

        Are you sure the "image" exists?

        $ HEAD http://www.***your-domain***.net/header_glow.jpg 404 Not Found Connection: close Date: Sat, 28 Aug 2004 18:37:40 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 Content-Type: text/html Client-Date: Sat, 28 Aug 2004 18:36:56 GMT Client-Peer: 66.150.161.140:80 Client-Response-Num: 1 X-Powered-By: PHP/4.3.4
        --
        b10m

        All code is usually tested, but rarely trusted.
        Man that's wierd.
        I used your image link instead of mine and that doesn't work.
        Is it possible that the site hosting your image is protected against "leachers" ?
        (people using your content for thier own sites)
        Calling the image alone (right clicking) will send no HTTP_REFERER whereas your frameset does. My guess is that it would work from www.ballandshaft.net/cgi-bin, but that doesn't help much because you probably don't have a cgi-bin there.
        Try putting the image on the same server as your script.

        traxlog
Re: Broken Images....I don't understand
by wfsp (Abbot) on Aug 28, 2004 at 17:13 UTC
    If you quote the file name in the html you may have more luck:

    <img src=\"$imagePath\">
    The same in the body tag.
    (untested)

      This would be required, if we are talking about XHTML, but we are not.

        Yes. And it serves me right for not testing it first. I am currently converting a site to XHTML and have become sensitive to 'loose' html!

      Went ahead and gave that a whirl, still no luck. Thanks tho.
Re: Broken Images....I don't understand
by Spidy (Chaplain) on Aug 28, 2004 at 17:42 UTC
    Maybe try this:

    <img src=${imagePath}.jpg>

    I know that it's worked that way for me with html files, but I don't know if it would work with images...
    Of course, you're going to have the change the .jpg part depending on what kind of image your using.

    Spidy

      I believe his imagePath already contains the full path up to the file extention, otherwise the file cannot be found without .jpg, and there is no way that he can right click and view image.

      Sigh...no go. Thanks for your help tho.
Re: Broken Images....I don't understand
by Popcorn Dave (Abbot) on Aug 28, 2004 at 18:36 UTC
    Does it work if you don't use the HERE doc? Have you tried just using print statements to print the HTML?

    Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.
      I'm sorry, what do you mean by the HERE doc?
        HEREDOC is this kind of print behaviour:
        print <<END; Hello, World! END
        What he means is if you've tried using something like this:
        print "<img src=$imagePath>";
        BTW, I've tried the url you spplied (http://www.ballsandshaft.net/header_glow.jpg) and I've got a page not found here, so, the image is NOT there...

        Best regards,
        my ($author_nickname, $author_email) = ("DaWolf","erabbott\@terra.com.br") if ($author_name eq "Er Galvão Abbott");
      Yeah, I tried it with just print statements too. No luck. Thanks tho.
Re: Broken Images....I don't understand
by pg (Canon) on Aug 29, 2004 at 01:15 UTC

    There might be a simple answer. Most browsers allow you to turn off pictures. Check your browser setting see whether that's the case.

    For example, if you use IE, just go tools->internet options->advanced->multimedia->show pictures. It has to be checked, otherwise pictures will not be downloaded, and you have to do the right click thing to manually download(This meets your description of the problem).

Re: Broken Images....I don't understand
by mpeg4codec (Pilgrim) on Aug 29, 2004 at 07:17 UTC
    Make sure your browser is not fetching it from the cache. Hitting the reload button forces the browser to download a fresh version of the page, with the updated <img> tag. It may be as simple as this.
Re: Broken Images....I don't understand
by bart (Canon) on Aug 29, 2004 at 10:31 UTC
    In theory, you have to HTML-escape tag attributes. I'm guessing your actual URL does contain more "weird" characters than the example URL you gave here.

    Oh, and despite what other people have been saying here, you should put quotes around the attribute. Though browsers are very lax, if an attribute contains even slightly offbeat characters (such as a slash or a colon), attribute parsing may stop right there, and you get an incomplete URL.

Re: Broken Images....I don't understand
by chanio (Priest) on Aug 30, 2004 at 05:04 UTC
    Just guessing,

    Have you tried changing the name of the image? Try using some name that doesn't have the word 'header', ok?

    Hope that it helps!

    .{\('v')/}
    _`(___)' __________________________

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-20 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found