Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / April 2007



Tip: Looking for answers? Try searching our database.

send XML from Flash to PHP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cosu - 17 Apr 2007 16:04 GMT
hi!

i create an xml in flash and want to save it on the server.  i user
my_xm.send("script.php"); to send the created xml, but don't know how to handle
it in PHP in order to save the file on the disk.  any suggestions?

thank you.
MotionMaker - 17 Apr 2007 21:23 GMT
More of a PHP question than a Flash question. But I attached code I have used
with PHP 4.3 +

Also you may want the Flash movie to know if the PHP script succeeded and thus
you will want  http://livedocs.macromedia.com/flash/8/main/00002879.html.

A full example is located at
http://www.hosfordusa.com/ClickSystems/courses/flash/examples/XMLPHP/EX01/XMLPHP
EchoEx01_Doc.php.

<?php
header('content-type: application/xml; charset="iso-8859-1"');
/*----------------------------------------------------------------------
    Lon Hosford: http://www.lonhosford.com

    Purpose:            Simple example Flash XML to PHP and Back

    Version history:
        Number:            1.00.00
        Date:            9/15/2005
        File name:        XMLPHPEchoEx01_Response.php
        Programmer:        Lon Hosford: http://www.lonhosford.com
        Changes:        Original programming
------------------------------------------------------------------------
     Get data from PHP. Requires PHP 4.3 or greater.
---------------------------------------------------------------------*/
$xmlRequest = file_get_contents("php://input");

/*----------------------------------------------------------------------
     Optional dump to server side text file. Reminder your
    server folder needs to allow write and create permission
    for the file name selected.
------------------------------------------------------------------------
    File name to dump data from Flash
---------------------------------------------------------------------*/
$filename = "xmloutput.txt";
/*----------------------------------------------------------------------
     Open stream to file
---------------------------------------------------------------------*/
$fp = fopen( $filename,"w+");
/*----------------------------------------------------------------------
     Write to stream
------------------------------------------------------------------------
    Any text into file for testing in case nothing is received
---------------------------------------------------------------------*/
fwrite ( $fp, "Test" );
/*----------------------------------------------------------------------
     Data from Flash
---------------------------------------------------------------------*/
fwrite ( $fp, $xmlRequest );
/*----------------------------------------------------------------------
     Close stream
---------------------------------------------------------------------*/
fclose( $fp );
/*----------------------------------------------------------------------
     Echo data back to Flash
------------------------------------------------------------------------
     Create xml header to exh-
---------------------------------------------------------------------*/
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
/*----------------------------------------------------------------------
     Data received
---------------------------------------------------------------------*/
echo $xmlRequest ;

?>
cosu - 18 Apr 2007 10:45 GMT
thank you.  the php code seems ok.  it was the [b]$xmlRequest = file_get_contents("php://input");[/b] i didn't know.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.