Php 从jquery draggable写入XML的权限
从一个draggable div的stop事件开始,我通过ajax调用了一个php函数。该脚本保存XML时存在权限错误Php 从jquery draggable写入XML的权限,php,xml,permissions,draggable,file-permissions,Php,Xml,Permissions,Draggable,File Permissions,从一个draggable div的stop事件开始,我通过ajax调用了一个php函数。该脚本保存XML时存在权限错误 Warning: SimpleXMLElement::asXML(communities.xml) simpleelement.asxml failed to open stream: permission denied in c:\path\make_update.php. ajax调用在动态创建的div中完成,即div由脚本创建,保存xml的调用定义如下 echo "
Warning: SimpleXMLElement::asXML(communities.xml) simpleelement.asxml failed to open stream: permission denied in c:\path\make_update.php.
ajax调用在动态创建的div中完成,即div由脚本创建,保存xml的调用定义如下
echo " $('#".$node['ID']."').draggable({ stop: function(event, ui) { update_div('".$node['ID']."') } });\n";
function update_div(divid) {
width= $('#'+divid).width();
height=$('#'+divid).height();
coord =$('#'+divid).position();
dtop = coord.top;
dleft = coord.left;
name = "";
/* alert ('Finished dragging! '+divid+' '+width+' '+height+' '+dtop+' '+dleft); */
//define php info and make ajax call to update XML
$.ajax({
url: "make_update.php",
type: "POST",
data: { nodeid: divid, name: name, top: dtop, left: dleft, width: width, height: height },
cache: false,
success: function (response) {
if (response != '')
{
alert(response);
}
}
});
}
<?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']));
?>
ajax调用是这样完成的
echo " $('#".$node['ID']."').draggable({ stop: function(event, ui) { update_div('".$node['ID']."') } });\n";
function update_div(divid) {
width= $('#'+divid).width();
height=$('#'+divid).height();
coord =$('#'+divid).position();
dtop = coord.top;
dleft = coord.left;
name = "";
/* alert ('Finished dragging! '+divid+' '+width+' '+height+' '+dtop+' '+dleft); */
//define php info and make ajax call to update XML
$.ajax({
url: "make_update.php",
type: "POST",
data: { nodeid: divid, name: name, top: dtop, left: dleft, width: width, height: height },
cache: false,
success: function (response) {
if (response != '')
{
alert(response);
}
}
});
}
<?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']));
?>
函数更新\u div(divid){
宽度=$('#'+divid).width();
高度=$('#'+divid).height();
coord=$('#'+divid).position();
dtop=coord.top;
dleft=坐标左;
name=“”;
/*警报('Finished Draging!'+divid+''+width+''+height+''+dtop+''+dleft)*/
//定义php信息并进行ajax调用以更新XML
$.ajax({
url:“make_update.php”,
类型:“POST”,
数据:{nodeid:divid,name:name,top:dtop,left:dleft,width:width,height:height},
cache:false,
成功:功能(响应){
如果(响应!='')
{
警报(响应);
}
}
});
}
xpath(//COMMUNITY[@ID='$nodeid']);
$node=$returnArray[0];
$node->TOP=$TOP;
$nodes->asXML('communities.xml');
返回$node->TOP;
}
echo make_更新(修剪($_请求['nodeid'])、修剪($_请求['name'])、修剪($_请求['top'])、修剪($_请求['left'])、修剪($_请求['width'])、修剪($_请求['height']);
?>
正在从XML文件检索数据。问题是保存文件的权限。在其他地方,我可以保存XML。这里的区别在于脚本是从
.draggable()
调用的。在这种情况下,如何定义保存XML的权限?XML及其所在目录的权限是读写权限。它与服务器上定义的文件夹/文件权限有关。打开XML文件驻留在Windows中的文件夹的属性,并确保服务器可以读取/写入该文件夹