[英]PHP writing to file on server
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. 如果需要,我将提供任何其他信息。
Use realpath — Returns canonicalized absolute pathname
Use realpath-返回规范化的绝对路径名
file_put_contents(realpath("somedirectory/somefile.txt"),$content); file_put_contents(真实路径( “somedirectory / somefile.txt”),$内容);
and check the permission for folder and file whether you have write access.
并检查文件夹和文件的权限,是否具有写访问权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.