LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-10-2014, 02:31 AM   #1
zama
LQ Newbie
 
Registered: Mar 2012
Posts: 29

Rep: Reputation: Disabled
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 ?
 
Old 04-10-2014, 04:17 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,950

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
Try View/Source in your browser to see what your script has done.
 
Old 04-10-2014, 10:32 AM   #3
dugan
Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 5,006

Rep: Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560
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.

Last edited by dugan; 04-10-2014 at 10:34 AM.
 
Old 04-10-2014, 10:40 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,950

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
For example, this line needs to be fixed:
Code:
echo "<img src="/home/zaman/graph/SSDGhistory.png" alt="DG-Reports">"
 
Old 04-10-2014, 02:57 PM   #5
John VV
Guru
 
Registered: Aug 2005
Posts: 13,536

Rep: Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808
the folder would be relative to what is set as "documentroot"
or
be accessible from the net with a ip address
 
Old 04-23-2014, 05:56 AM   #6
zama
LQ Newbie
 
Registered: Mar 2012
Posts: 29

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
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 .
 
  


Reply

Tags
apache, bash scripting, cgi, html


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help me to decide correct fully loaded CD/DVD image of Debian 6 shivaa Debian 9 02-18-2013 02:05 AM
setting background image in cgi shell script rajib_145 Linux - General 1 05-18-2012 05:37 AM
background image for cgi file kaplan71 Programming 2 03-29-2008 08:20 AM
How to show image in CGI script? Barca Programming 2 07-23-2005 06:22 PM
C++ CGI Program(Tell Me what you think) karlan Programming 0 03-29-2004 02:33 PM


All times are GMT -5. The time now is 08:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration