开发者

Permissions for writing to XML from jquery draggable

From the stop event of a draggable div, I call a php function through ajax. There are permission errors when that script saves the XML.

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

The ajax call is done in a div created dynamically, i.e. the div is created by a script and the call to save the xml is defined like this.

echo "  $('#".$node['ID']."').draggable({ stop: function(event, ui) { update_div('".$node['ID']."') } });\n";

The ajax call is done like this.

    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']));

?>

The data is being retrieved from the XML file. The problem is the permission to save the file. Elsewhere I am able to save the XML. The difference here is that the script is called from .draggable(). How do I define the permissions to be able to save the XML in that scenario? The permission on the XML and the directory where it is located are read write.


It has to do with the folder/file permissions defined on the server. Open the properties for the folder that the XML file resides in Windows and make sure your server can read/write to that folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜