开发者

file_get_contents function not working

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


Enable error reporting using display_errors and/or error_reporting.


Use:

echo $file_path;

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


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜