Current location: Hot Scripts Forums » Programming Languages » PHP » is this possible?


is this possible?

Reply
  #1 (permalink)  
Old 05-30-04, 06:23 PM
xxtruepinoyxx xxtruepinoyxx is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
is this possible?

I was wondering if the following is possible:

can i place images in the root folder of my site (ex: /home/username/folder ) and have images display using PHP?

any help would be appreciated. thanks!
Reply With Quote
  #2 (permalink)  
Old 05-30-04, 07:59 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Its very possible.

But, there are many things to look out for if you include files otherwise it can be very insecure.
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
  #3 (permalink)  
Old 05-31-04, 12:15 AM
xxtruepinoyxx xxtruepinoyxx is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Acecool
Its very possible.

But, there are many things to look out for if you include files otherwise it can be very insecure.
how would i go about displaying images from the root folder? i tried a php include but it didnt work.

and what are the things i have to look out for using include files?

thanks!
Reply With Quote
  #4 (permalink)  
Old 05-31-04, 02:42 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
to display images using php, use this simple line:
PHP Code:

echo '<img src="mypic.png" alt="Me" />'
you have to use HTML to display contents!
php is used to process these contents before displaying them..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #5 (permalink)  
Old 05-31-04, 01:28 PM
xxtruepinoyxx xxtruepinoyxx is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by NeverMind
to display images using php, use this simple line:
PHP Code:

echo '<img src="mypic.png" alt="Me" />'
you have to use HTML to display contents!
php is used to process these contents before displaying them..
i know that you have to use HTML to display contents.

i guess i wasn't clear on what i was asking.

--> if i place my images in the root folder (not the public folder -- ex: /home/username/folder), would i be able to display them still?

currently all content is in the folder "/home/username/public_html" but i wanted to know if i'm able to put the contents in the folder outside of the public folder and still be able to display. am i making sense?

Last edited by xxtruepinoyxx; 05-31-04 at 01:36 PM.
Reply With Quote
  #6 (permalink)  
Old 06-02-04, 12:08 AM
xxtruepinoyxx xxtruepinoyxx is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
anyone have any ideas???
Reply With Quote
  #7 (permalink)  
Old 06-02-04, 01:34 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,

I think it's possible, just like you can display text file contents above doc root. But because it is an image, I guess you'd first have to make it available for PHP to process as a resource and then create/display the image dynamically, rather than simply referring to the image file directly from HTML.

Image is one thing I just don't get to use at all, so I can't comment on it deeply, but you may want to take a look at the PHP Image functions. Functions like imagecreatefrompng() may get you started.

Docmentation: http://ca.php.net/image
__________________
Blavv =|
Reply With Quote
  #8 (permalink)  
Old 06-02-04, 01:44 AM
Pineapple Pineapple is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Phoenix, AZ
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
You don't need to use PHP's manipulation image functions.

<?php
// Change to image/pjpeg if necessary
header("Content-type: image/gif:);
readfile('/path/to/image.gif');
?>

Then refer to your PHP script in the <img> tag:

<img src="get_image.php">
__________________

Pineapple Technologies :: http://www.pineappletechnologies.com

Lore - a powerful knowledge base management system which uses PHP, MySQL, and Smarty templates.

QuizShock - an advanced quiz management system using PHP, MySQL, and Flash.
Reply With Quote
  #9 (permalink)  
Old 06-02-04, 02:22 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hey Pineapple,

That's neat - I never thought of that...!
__________________
Blavv =|
Reply With Quote
  #10 (permalink)  
Old 06-02-04, 10:51 PM
xxtruepinoyxx xxtruepinoyxx is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Pineapple!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 10:37 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.