Linking to files outside public_html

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
tehhparadox
Forum Newbie
Posts: 18
Joined: Thu Oct 01, 2009 11:55 am

Linking to files outside public_html

Post by tehhparadox »

Hi guys

Well, my problem is that I can't link to a .php file outside public_html. I made a new folder, and when I put the file inside it, people can't just type the URL in and go to it. I want to open this file after a password has been confirmed and I have no idea how to.

I'll be grateful for any help
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Linking to files outside public_html

Post by kaisellgren »

Code: Select all

/home/account/public_html/index.php
/home/account/non_public/path/to/file.txt
index.php

Code: Select all

<?php
 
echo file_get_contents('../non_public/path/to/file.txt');
tehhparadox
Forum Newbie
Posts: 18
Joined: Thu Oct 01, 2009 11:55 am

Re: Linking to files outside public_html

Post by tehhparadox »

thanks Kai!
I needed that info. I can't check that code just now cos my hosting's down, but thanks all the same.
Post Reply