Can't pass a xml from as3 to php

So I have these two scripts that comunicate with each other to create a xml file online. The way I have it now, AS3 swf sends a few variables to a php script to write. I got the creating part, but for some reason, the php does not write a xml file. I tried changing the variable to a simple "foobar" string, and it works. But If I do a:

var temp:XML = new XML(<test></test>);

It doesen't write it. So what's up, is this normal?

AS3

function SaveXml(inputxml:XML){
    var temp:XML = <teste></teste>;
    var variables:URLVariables = new URLVariables();
    variables.xmlfile = temp;
    variables.folder = TestProperties.Username;
    var request:URLRequest = new URLRequest("savexml.php");
    request.method = URLRequestMethod.POST;
    request.data = variables;

    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;

    try{
        loader.load(request);
    }
    catch (error:Error) {
        trace("Unable to load URL");
    }

    loader.addEventListener(Event.COMPLETE, completeHandler);

    function completeHandler(e:Event)
    {
                //something when complete;
    }
    }

PHP

<?php

date_default_timezone_set('GMT');

$xmlfile = $_POST["xmlfile"];
$folder = $_POST["folder"];
$filename = date('ymdhis').".xml";

if(! file_exists("./user/".$folder."/")){
    mkdir("./user/".$folder."/", 0777);
}

$handle = fopen("user/".$folder."/".$filename, 'w+');
fwrite($handle, $xmlfile );
fclose($handle);

echo "result=success";
?>

Answers


You can't create a xml in flash like you did.

var temp:XML = <teste></teste>;

Because there is no object like in your file. What you need to do is provide a string as a parameter when instantiating the XML object.

So, you should do something like below,

var temp:XML = new XML("<teste></teste>");

Now your code can send xml to php.


Need Your Help

setcors / getcors for individual files

google-cloud-storage

I tried doing setcors / getcors to a single file, but I get

How to remove strings of length 5 from a set?

java string set

I want to remove strings of length 5 from a set, but it keeps outputting the set itself.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.