LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Image could not be loaded using CGI program (https://www.linuxquestions.org/questions/programming-9/image-could-not-be-loaded-using-cgi-program-4175501185/)

zama 04-10-2014 01:31 AM

Image could not be loaded using CGI program
 
I am writing to write a cgi script to display a png image in a browser. When user clicks on the 'Submit' form in the HTML page , the CGI program is called to display the image .

But this is not working for me . When the script is executed , the text in alt section from img src HTML tag is displayed , rather than the image

The following is the snippet of CGI code.

!/bin/bash

echo "Content-type: text/html"

echo ""

echo "<html>"
echo "<body>"
echo "Hi"

echo "<img src="/home/zaman/graph/SSDGhistory.png" alt="DG-Reports">"
echo "</body>"
echo "</html>"

If I write the same code in plain HTML page , the PNG image is displayed fine.

Please suggest what I am missing in the code to display the image without any errors ?

NevemTeve 04-10-2014 03:17 AM

Try View/Source in your browser to see what your script has done.

dugan 04-10-2014 09:32 AM

Shouldn't that be:

Code:

file:///home/zaman/graph/SSDGhistory.png
Quote:

If I write the same code in plain HTML page , the PNG image is displayed fine.
If you're comparing a CGI generated page that you loaded from a server, to a "plain HTML page" that you loaded from disk, then one big variable is how you loaded them. A page loaded from a server and a page loaded from disk do not behave in the same way.

NevemTeve 04-10-2014 09:40 AM

For example, this line needs to be fixed:
Code:

echo "<img src="/home/zaman/graph/SSDGhistory.png" alt="DG-Reports">"

John VV 04-10-2014 01:57 PM

the folder would be relative to what is set as "documentroot"
or
be accessible from the net with a ip address

zama 04-23-2014 04:56 AM

Quote:

Originally Posted by John VV (Post 5150266)
the folder would be relative to what is set as "documentroot"
or
be accessible from the net with a ip address

Changing the path to something like http://path_known_to_webserver/SSDGhistory.png resolved the issue .


All times are GMT -5. The time now is 02:53 PM.