0

My hosting provider recently upgraded it's Apache engine and also php to 7.2

Now I'm getting a very weird issue..

My code:

$GAFData = file_get_contents('./p.dta');

It is working as it should on my development server (wamp), but i upload to my production server it is not working, it's gives following error:

PHP Warning:  file_get_contents(./p.dta): failed to open stream: No such file or directory in /home3/UserName/public_html/GAF/index.php on line 5

But it is present in the same directory as the script is.

I even tried to change the file permission to 777

What could be the issue, I have already tear of half of my hair.. but can't find what could be the issue, as this is just a very simple function I have used so many times.

Thanks in advance

Update-1:

As mentioned in so called duplicate link/anwser, I have even tried following:

$GAFData = file_get_contents(__DIR__ . '/p.dta');

Just like before it works fine on my development pc, but not on my server.

Emmanuel
  • 4,933
  • 5
  • 46
  • 71
Zakir_SZH
  • 466
  • 7
  • 21
  • Relative paths are relative to the *current working directory*, not to the file the code is in. – deceze May 16 '19 at 11:40

1 Answers1

-1

Did you try to use fully-qulified name of the file like so?

$GAFData = file_get_contents('/home/user/p.dta');
// where /home/user/ is you app root, you can replace it with $_SERVER['DOCUMENT_ROOT']