I have a very simple actionscript 3 class, used to upload an .xml file to a php script:
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.net.*;
public class loadXML2 {
//private var uploadURL:URLRequest;
private var file:FileReference;
private var _message:TextField;
public function loadXML2() {
file = new FileReference();
configureListeners(file);
var filter:FileFilter = new FileFilter("XML Files", "*.xml");
file.browse([filter]);
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.SELECT, selectHandler);
}
private function selectHandler(event:Event):void {
var request:URLRequest = new URLRequest();
request.url = "load.php";
request.method = URLRequestMethod.POST;
var file:FileReference = FileReference(event.target);
file.upload(request);
navigateToURL( request, "_blank" );
}
}
}
However I do not know PHP. Could anyone tell me what the script “load.php” should contain to echo out either the name of the uploaded file or its contents?
I’ve tried:
<?php
echo 'Begin';
echo $_FILES['file']['name'];
echo 'End';
?>
and
<?php
$xmldoc = $GLOBALS['HTTP_RAW_POST_DATA'];
echo 'Begin';
echo $xmldoc;
echo file_get_contents("$xmldoc");
echo 'End';
?>
which both only display ‘BeginEnd’, and nothing in between.
Thanks for any help.