?
Solved

Using Perl to Display Picture

Posted on 2006-11-29
7
Medium Priority
?
216 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:nebest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 18040604
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
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 18040870
You need to do

#!/usr/bin/perl
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $q = new CGI;
print $q->header('image/gif');
open IMG, "/home/p/pic.gif" or die "Can not open pic.gif $!\n";
binmode IMG
print <IMG>;
close IMG;
0
 

Author Comment

by:nebest
ID: 18041085

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.
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 48

Expert Comment

by:Tintin
ID: 18041532
What browser are you using?  Have you opened the image directly in the browser previously?
0
 

Author Comment

by:nebest
ID: 18041580
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?
0
 

Author Comment

by:nebest
ID: 18041622
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
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18041685
You can't mix content types (as you found out).
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question