MysticDrow
Technical User
Hi. I have been fighting the last few days with php to make it create an xml file. Actually it DOES create it but I'm not able to choose the name of the file from my AS3 code. Here is the AS3:
and here goes the php:
The code does NOTHING, but if I replace the line
$name = $xml->name;
with this one:
$name = "someMap.xml";
everything works perfectly and it creates a document named "someMap.xml". So the problem is the php file cannot read the xml format using just the simplexml "->" or it doesn't "know" i'ts simplexml. I also tried
$_xml = $GLOBALS["HTTP_RAW_POST_DATA"];
$xml = new SimpleXMLElement($_xml);
and even opening the "someMap.xml" file once it's created to get the name info but with no effect :/ Anyone could help me? Why doesn't it work and how can I fix it?
Thanks
Mystic
Code:
var myXMLText:String = "<?xml version='1.0' encoding='ISO-8859-1'?><contents><name>mapa.xml</name><mapa>hereGoesTheRealText</mapa></contents>";
var mapaXML:XML = new XML(myXMLText);
var urlRequest:URLRequest = new URLRequest("save.php");
urlRequest.data = mapaXML;
urlRequest.contentType = "text/xml";
urlRequest.method = URLRequestMethod.POST;
var xmlSend:URLLoader = new URLLoader();
xmlSend.addEventListener(Event.COMPLETE, loaded);
xmlSend.load(urlRequest);
and here goes the php:
Code:
<?php
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])){
$xml = $GLOBALS["HTTP_RAW_POST_DATA"];
$name = $xml->name;
$file = fopen($name,"wb");
fwrite($file, $xml);
fclose($file);
echo($GLOBALS["HTTP_RAW_POST_DATA"]);
}
?>
The code does NOTHING, but if I replace the line
$name = $xml->name;
with this one:
$name = "someMap.xml";
everything works perfectly and it creates a document named "someMap.xml". So the problem is the php file cannot read the xml format using just the simplexml "->" or it doesn't "know" i'ts simplexml. I also tried
$_xml = $GLOBALS["HTTP_RAW_POST_DATA"];
$xml = new SimpleXMLElement($_xml);
and even opening the "someMap.xml" file once it's created to get the name info but with no effect :/ Anyone could help me? Why doesn't it work and how can I fix it?
Thanks
Mystic