Groups | Blog | Home
all groups > flash actionscript > june 2005 >

flash actionscript : PHP is not receiving any data sent from Flash


ManinBlaq
6/7/2005 9:33:44 PM
I've been attempting to send an xml file to a PHP script, for quite sometime
...all in vain.

I've verified that my PHP script works, by submitting from a barebones web
form. Effectively, all it does is step through each POST key and prints the
value.

When I attempt to send xml data to the script: using myXML.send("url",
"_blank"); the page that is opens showing the results is always blank. (No
source what so ever).

What's more, I have attempted to use myXML.sendAndLoad("url", myreceivedXML)
-- and the myreceivedXML object is always null or blank. (When it should be an
fairly exact copy of my original xml document that I sent.)

Here is my flash code.

_global.map_xml = new XML();
_global.map_xml.ignoreWhite = true;
_global.map_xml.contentType = "text/xml";
_global.map_xml.xmlDecl = "xml=";

_global.map_xml.onLoad = function(success:Boolean){

if (success) {
_global.map_xml.send("http://blaqestnight.com/map/map.php", "_blank");
}
}

_global.map_xml.load("values.xml");


Here's my PHP script:
// Print test 1
$somecontent = $_POST['xml'];

print $somecontent;
print $_POST['xml'];

//Print test 2
foreach ($_POST as $value) {
Print $value;
}


The initial load is always successfull. I'm able to use the xml object to
initialize, but I'm trying to hand it off to the PHP script to write to disk
...and it never seems to be receiving it.

In another forum, it was mentioned that by putting the "xml=" in the
XML.xmlDecl property, you would be able to access the xml through $_POST['xml']
..without having to enable $HTTP_RAW_POST_VAR.
ManinBlaq
6/10/2005 12:01:42 AM
FYI: For anyone who cares ...

I was never able to get flash to receive the data through XML.sendAndLoad();
I had to overcome this by writing a small routine, that takes the string from
XML.toString() -- modifies slighty, and then packages it into a LoadVars
variable to send over to PHP. LoadVars.sendAndLoad() works fine. I capture it
on the PHP side as $_POST['xml'] ..and load it directly into a DOMXML function,
domxml_open_mem( $rawxml);

This works pretty well. I didn't test the XML.toString() raw output much --
you may not need to modify it at all.

(Basically, when outputting to the string ..Flash encapsulates all of the
values in double quotes "" .. my function, replaced those with single quotes,
so that the entire string could be placed within a single pair of double
quotes. Again, this may have been overkill .. I was trying several things to
fix this problem. Try it first with the raw data).
AddThis Social Bookmark Button