RE: [PHP] Calling Files from a different directory

From: Date: Thu, 03 Oct 2002 23:51:41 +0000
Subject: RE: [PHP] Calling Files from a different directory
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-118791@lists.php.net to get a copy of this message
> I have a page set up that loads the contents of a text file into an HTML > template using PHP. (i.e. something.com/page.php?include=1 where "1" is a > simple no-extension text file in the same directoy as page.php). Is there > a > way to modify the PHP code in the template page to search for the included > page in another directory? Right now, the only way to do it is to have the > URL as "page.php?include=files/1". > > Currently, here is the code I use to takes the $include URL variable and > makes the file accessible in the template: > > $info = file($include); Can I get the URL to your server, please, so I can pull up page.php?include=/etc/passwd ?? Thanks, I would really appreciate that. But seriously, I really hope you are validating what $include is. If you want the file to be included from a different directory, then you have to pass some flag/variable to PHP to tell it where to look. If you always want it to be in the same dir, then use $info = file('files/' . $include); ---John Holmes...

« previous php.general (#118791) next »