Good day to all!

Please help me correct this kind of error:

Warning: file_get_contents (/papka/file.dat) failed to open stream: No such file or directory in

Warning: file_put_contents (/papka/file.dat) failed to open stream: No such file or directory in

Theoretically, I understand that php cannot find /papka/file.dat , although file.dat was not there, I thought to create a “pen”, and the error would disappear, but no, the error was hanging and hanging. The rights to the folder /papka/ 777 and the file dat 644 . What could be the reason? Even dirname (__FILE__) does not help.

  • It is difficult to say without a specific example, apparently still there is a mistake somewhere. However, it is necessary to consider it on a specific example, on an artificial one it looks like a completely inexplicable glitch. - cheops
  • If in file_get_contents (); specify the full path of the site with http: // then the error disappears, but in this case it is file_get_contents, but put_contens () cannot be specified http: //. : / - Webmaster
  • Yes, it downloads over the network, so file_get_contents () can extract the file by requesting it from the server. When you access a file, do you specify an absolute or relative path? - cheops
  • I specify the absolute path, including from http: // ... - Webmaster

1 answer 1

Restrictions may be:

  • At the PHP configuration level (for example, open_basedir).
  • At the web server configuration level
  • At the level of the environment (chroot, rights to folders, etc.)

Most often, the problem is trivial and consists of incorrect paths: a relative path is used in one place and an absolute path in another.