php file_put_contents 出错,这是哪里的问题 (php 创建文件失败,提示无法打开,请高手指教!)

同城网 生活常识 2023-02-04 19:48:42 77 0

php file_put_contents 出错,这是哪里的问题 (php 创建文件失败,提示无法打开,请高手指教!)

php file_put_contents 出错,这是哪里的问题

出现failed to open stream: Permission denied in是apache运行用户没用权限去访问指定的文件了,所以导致目录文件打不开了。

检查目标文件的地址 注意要使用相对地址, 非webroot 的地址要设置权限

php 创建文件失败,提示无法打开,请高手指教!

Warning: file_put_contents(/data/home/qxu1002120378/htdocs/) [function.file-put-contents]: failed to open stream: Is a directory

从上面的提示,结合代码来看,建议在调用

file_put_contents($filename, $content);//输出

代码之前,查看一下 $content 的值及类型 。

file_put_contents函数的原型定义如下:

nt file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] )

其中 $data 参数类型可以是 string,array 或者是 stream 资源。