Reputation: 25
I'm trying to write to a file on my local server and I can't figure out why, I haven't found any good reason why what I'm doing should not work.
What I've tryed:
file_put_contents("./lol.txt", "Contents");
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/lil.txt", "Contents");
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "lal.txt", "Contents");
file_put_contents("lel.txt", "Contents");
I will provide any additional info if needed.
Upvotes: 1
Views: 1176
Reputation: 325
Use realpath — Returns canonicalized absolute pathname
file_put_contents(realpath("somedirectory/somefile.txt"),$content);
and check the permission for folder and file whether you have write access.
Upvotes: 2