从SimpleXMLElement保存XML打开流失败


Save XML from SimpleXMLElement failed to open stream error

XML文件和保存该文件的服务器上的文件夹在Windows Vista、IIS 7环境中是完全读写的。调用asXML函数返回此警告,并且文件未更新。

Warning: SimpleXMLElement::asXML(communities.xml) simpleelement.asxml failed to open stream: permission denied in c:'path'make_update.php.

make_update.php文件更新XML中的节点。

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
function make_update( $nodeid, $name, $top, $left, $width, $height ) {
$nodes = new SimpleXMLElement('communities.xml', null, true);
$returnArray = $nodes->xpath("//COMMUNITY[@ID='$nodeid']");  
$node = $returnArray[0]; 
$node->TOP = $top;
$nodes->asXML('communities.xml');
return $node->TOP;
}
echo make_update(trim($_REQUEST['nodeid']),trim($_REQUEST['name']),trim($_REQUEST['top']),trim($_REQUEST['left']),trim($_REQUEST['width']),trim($_REQUEST['height']));
?>

除了要读写的文件外,还必须对包含XML文件的文件夹设置权限。由owner, system, user, iisuser执行

我有同样的问题,我运行IIS 7与php我有'未能打开流错误'与SimpleXMLElement::asXML。

我通过授予"每个人"写权限来解决这个问题。这个解决方案只适用于内部网站,因为它有风险。

user823527的解决方案不适合我。

更新:我通过授予'IUSR'和'IIS_USRS'的写访问权限修复了这个问题