0

I'm trying to save a file like this:

echo file_put_contents("/tmp/foo.txt","Hello World. Testing!");

But the file /tmp/foo.txt is not created.

I'm on Ubuntu 18. My code is at /var/www/html/index.php and I'm requesting localhost/index.php.

tirenweb
  • 30,963
  • 73
  • 183
  • 303
  • Does your webserver account have access to `\tmp` – RiggsFolly Feb 06 '19 at 13:05
  • @RiggsFolly the permissions of `/tmp` directory are these: `drwxrwxrwt 30 root root 4096 Feb 6 13:01 . ` – tirenweb Feb 06 '19 at 13:06
  • Try writing the file to `file_put_contents("foo.txt","Hello World. Testing!");` does that work – RiggsFolly Feb 06 '19 at 13:07
  • 1
    See [How to get useful error messages in PHP?](https://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php) – Phil Feb 06 '19 at 13:08
  • Possible duplicate of [How to get useful error messages in PHP?](https://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php) – Nico Haase Feb 06 '19 at 13:50

0 Answers0