files that are outside of htdocs?

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
ramblin54321
Forum Commoner
Posts: 32
Joined: Wed Nov 18, 2009 5:31 am

files that are outside of htdocs?

Post by ramblin54321 »

Greetings,
what I want to do is prevent direct access to files by placing them outside of htdocs and access them with a login script that is in htdocs. I went into php.ini both in apache/bin and in windows and uncommented this line: include_path = ".;C:\xampp\php\includes\"
Then I put a jpg file in there and tried to access it from the web page as follows:
<img src="C:/xampp/php/includes/284.jpg">
The image doesn't show. How do I make my web page access files that are outside of
htdocs? I've tried using both forward and backward slashes.
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: files that are outside of htdocs?

Post by iankent »

You cant, not that way anyway!

Using a URL you can only access files within the htdocs folder. Apache (and most other servers) wont allow you to directly access files above the document root.

What you can do with files in the include path is include them via PHP, e.g.
include('/path/to/inclues/blah.php');

Alternatively you could read in the file contents and output them via PHP (e.g., to display an image inside the includes folder), but you can't use HREF to link directly to it, no matter what path you attempt to put in there.

hth
ramblin54321
Forum Commoner
Posts: 32
Joined: Wed Nov 18, 2009 5:31 am

What about music files?

Post by ramblin54321 »

Greetings,
I figured out that I can use redirect and session variables to keep files from direct access as long as they aren't like the captcha file that is needed in the initial login script but what about music files? How can I allow the user to listen to an mp3 or partial mp3 without having direct access to the file? I see that even with direct access, the save and save as options are greyed out and inoperable for music files in internet explorer. I guess that's the best I can do?
Post Reply