Jake
Jake

Reputation: 26137

Local File inclusion in PHP

I have a file called config.php in application root \var\www\html and it can be reached at going to http://abc.efg.com/config.php

I also have a file called index.php, in the same folder which has some code to include the file name from a query string parameter and read from it.

Ex: include_once($_GET["page"].php)

I would like to execute a local file inclusion, by passing some php code that would make that include statement print the contents of config.php

Upvotes: 0

Views: 491

Answers (1)

paki leonel
paki leonel

Reputation: 94

First, it is not advisable to use it in this way because it leaves a flaw in your site so you can just do:

if( isset($_GET['page']) && $_GET['page']=='config' ) {
    include 'config.php';
}

However, your problem was at the level of .php, it was necessary to put in string '.php'

Upvotes: 1

Related Questions