Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

photo does not display on HTML page in Linux

by Anonymous Monk
on Jun 01, 2017 at 16:13 UTC ( #1191867=perlquestion: print w/replies, xml ) Need Help??

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

I have constructed an interactive HTML page by using a Perl 'HERE' doc. I need to display a jpg on the page. All is well running in windows7 but I need it to run in Centos. The produced HTML file looks OK on Linux but the photo does not display...I have double-checked that the address is OK.

Any thoughts would be appreciated.

  • Comment on photo does not display on HTML page in Linux

Replies are listed 'Best First'.
Re: photo does not display on HTML page in Linux
by kennethk (Abbot) on Jun 01, 2017 at 16:23 UTC
    This sounds like an issue with an <img> tag (particularly the src attribute), and not a Perl cross-platform issue. Have to tried copying the image URL into your browser address field? This is most often caused by either a change in pathing or a permissions issue.

    So, as zentara says, please paste your here-doc into a set of <code> tags as a reply to this thread.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: photo does not display on HTML page in Linux
by Corion (Pope) on Jun 01, 2017 at 16:21 UTC

    You can help us help you better by answering some of these quetions:

    Have you investigated if the image is displayed properly without Perl?

    Where exactly is the problem? Is the problem in creating the proper HTML from Perl or from serving the JPEG image from Perl? Is there a web server involved? What does its error log say?

    What is the address of the HTML page? What is the address of the JPEG image?

      <IMG SRC="/net/home2/ceb/bmcclint/data/brendan.jpg" WIDTH=850 HEIGHT=1000>

      The HTML is OK on windows and is identical on Linux except the address is different (of course). No web server

        This has very little to do with Perl and is all about HTML and how your browser displays local resources.

        Are you sure that your browser will interpret this address as an address that is supposed to be loaded from a file?

        Personally, I would either add an address relative to the HTML file, like (assuming that the HTML file lives in /net/home2/ceb/bmcclint):

        <IMG SRC="./data/brendan.jpg" WIDTH=850 HEIGHT=1000>

        Alternatively, find out how your browser interprets file:// URIs, and give it the appropriate file:// URI. Maybe it is

        <IMG SRC="file://net/home2/ceb/bmcclint/data/brendan.jpg" WIDTH=850 HE +IGHT=1000>

        But again, none of this has anything to do with Perl, so most likely you will find better help in the documentation (or internet searches) for your browser.

Re: photo does not display on HTML page in Linux
by zentara (Archbishop) on Jun 01, 2017 at 16:20 UTC
    You probably should help us out by showing us your HERE doc code.

    I'm not really a human, but I play one on earth. ..... an animated JAPH
Re: photo does not display on HTML page in Linux
by (anonymized user) (Curate) on Jun 01, 2017 at 20:10 UTC
    The most common cause of this problem is not being on top of how you organise and reference files on the webserver. The fact that the html displays means that the location of the html is configured correctly. So now you need to reference the image relative to wherever you configured the document root on your webserver. For example, if the images are in a lower directory than the html you need to refer to them relative to where the html is stored. If the html and images are in subdirectories of the same location then you need to refer up and down a directory. Just trace where it is and configure accordingly.

    One world, one people

Re: photo does not display on HTML page in Linux
by sundialsvc4 (Abbot) on Jun 02, 2017 at 14:35 UTC

    No, I did not take the time to dive into the code sample, but another very-common problem in “Windows vs. Linux/Unix” – regardless of programming language – is that Windows uses a case-insensitive file system, but Unix/Linux is case-sensitive.   (Macintoshes offer you the choice, but default to a case-insensitive file system as a nod to their own pre-Unix past.)

    So, a request for Perl.jpg, when the underlying file is perl.jpg, will work on a Windows-hosted server, but not on a Linux-hosted one.   Linux will return 404 Not Found simply due to the upper-case “P” vs. the lower-case “p.”   (Similarly, Linux will allow two files to co-exist in the same place, whose names differ only by character-case.   Windows will not.)

    The type of operating system being used on the client side does not matter at all.

    Web servers ordinarily handle the “forward vs. backward slashes in paths” issue for you transparently, but my experience with modules that are supposed to address filename case-sensitivity – such as Apache’s mod speling (sic ...) is that they simply do not work at all. (And, many are the times when I wished that they did, and have in fact been assured that they do.)

    If you observe the page-load (on Linux) using the diagnostic tools of a web browser, you will ordinarily see the “missing” resources returning a 404 Not Found (or some other 4xx code), and you may or may not(!) see a “broken link” icon on your screen.

    Another good technique is to copy-and-paste the offending URLs, from the source-code of the page that does not display the image,taking care to copy from the actual HTML data that was transmitted to your browser, not from its source file on the host).   Paste this URL into the address-bar of a new browser tab or window, and observe any messages or error-indications that crop up either on the display or in the browser’s debugger.   (Also notice whether the transmitted URL is somehow different from what you had expected it to be, based on your comparison of the transmitted value to the source.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1191867]
Approved by Marshall
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2020-12-05 19:23 GMT
Find Nodes?
    Voting Booth?
    How often do you use taint mode?

    Results (65 votes). Check out past polls.