views:

44

answers:

3

Hi All,

I have some problem with file_get_contents() function, it not working properly when I tried to read URL like

"http://google.com"

is accessible but when I tried to access any file like "classes/connect_temp.txt" it is not accessible.

Here is some code i use

$file_path =realpath('./')."/classes/connect_temp.txt";
    $temp_cont = file_get_contents($file_path);
    if(empty($temp_cont)){$temp_cont=$this->dbSetings;}

What should I change in code or which config settings should I check of it.

Please Help me on this problem

A: 

Enable error reporting using display_errors and/or error_reporting.

Sjoerd
it is enable, No error getting
parag
A: 

Use:

echo $file_path;

To check what file the code is really trying to read.

Matijs
A: 

Maybe try curl ?
Sample..

$ch = curl_init("path-to-the-file");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);      
curl_close($ch);
echo $output;
kanenas.net