Page 1 of 1

files that are outside of htdocs?

Posted: Wed Nov 18, 2009 5:34 am
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.

Re: files that are outside of htdocs?

Posted: Wed Nov 18, 2009 5:38 am
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

What about music files?

Posted: Wed Nov 18, 2009 5:16 pm
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?