即使 is_writable()
返回 true,我也无法写入文件。当然,该文件存在并且显然是可读的。这是代码:
$file = "data";
echo file_get_contents($file)."<br>";
echo is_writable($file) ? "is writable<br>" : "not writable<br>";
if (file_put_contents($file, "ghijkl", FILE_APPEND) === FALSE) echo "failed<br>";
echo file_get_contents($file)."<br>";
这是输出:
abcdef
is writable
failed
abcdef
最佳答案
所以只需要检查文件系统中的可用空间
就我而言
我在控制台输入:
df -h
文件系统大小已用可用容量安装在
/dev/da0s1f 4.3G 4.0G -68M 102%/usr
释放空间,然后函数 file_put_contents 开始工作
关于PHP is_writable() 返回 true 但 file_put_contents() 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11238809/