Link to home
Start Free TrialLog in
Avatar of nebest
nebest

asked on

Using Perl to Display Picture

my directory structure is /home/p/public_html/cgi-bin/
I am trying to display a pic (using perl)outside of public_html ... I tried doing      

header ('image/gif');
print "<IMG SRC=\"/home/p/pic.gif\">";

but when i render it i realise it is looking for the picture  at www.servername.com/home/p/pic.gif 
and i guess since it doesn't have permission for /home/p it just diplays the red x.  

How can i solve this problem?

Thanks
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Yes, public_html is normally set up for everyone to read. You could grant read access to all on the diretory /home/p
Your HTML may also be set up to define a base reference point of /home/p/public_html
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nebest
nebest

ASKER


I tried using the suggestion by Tintin and I get a bunch of garbled text printed to screen ... what do i need to do to convert it to an actual image.
What browser are you using?  Have you opened the image directly in the browser previously?
Avatar of nebest

ASKER

I am using internet explorer.  I can open the image perfectly directly when its in public_html.  I know its reading the image file, can you give me an idea why i would see garbled data rather than pic. is there some header i may not be including?
Avatar of nebest

ASKER

The code you sent works perfectly, thank you... I guess it has something to do with the fact that I am also printing text  data in the same perl script.  I just tried using your code without any other code and it works.  

Thanks for your help
You can't mix content types (as you found out).