PHP无法打开流:是目录 [英] PHP failed to open stream: Is a directory
问题描述
非常简单的PHP脚本,我在我个人设置的Ubuntu Web服务器上的EE模板中运行.
Very simple PHP script I'm running within an EE template on an Ubuntu Webserver I set up personally.
我知道它与权限有关,并且我已经更改了要尝试以Apache用户身份写入的目录的所有者.
I know it has something to do with permissions, and I've already changed the owner of the directory I'm trying to write as being the Apache user.
<?php
$dir = 'export';
$drop =' {exp:ajw_export
sql="SELECT member_id, screen_name, email FROM exp_members"
format="xml"
} ';
echo $dir;
file_put_contents($dir, $drop);
?>
我得到的错误是:
遇到PHP错误
严重性:警告
消息:file_put_contents(export):无法打开流:是目录
Message: file_put_contents(export): failed to open stream: Is a directory
文件名:libraries/Functions.php(689):eval()的代码
Filename: libraries/Functions.php(689) : eval()'d code
行号:16
推荐答案
您的问题是您没有定义实际的文件,而只是定义目录.
Your problem is that you're not defining the actual file, only a directory.
$file = $dir . '/export.txt';
file_put_contents($file, $drop);
否则,PHP将如何知道将内容放置在何处?
Otherwise, how will PHP know where to place the content?
这篇关于PHP无法打开流:是目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!