mam wspaniały kod ktory przesyła mi dane xml do php i zapisuje do pliku xml
<?php
$fh = fopen("themes/test/test.xml", 'w') or
die("can't open file"); $xml ='<'.'?xml version="1.0" encoding="utf-8"?'.'>'. "\r\n" .$HTTP_RAW_POST_DATA ;
$odp="wyslano dane \r\n";
?>
i kod as3
function SendToURLExample(event:MouseEvent):void {
trace(xml)
var xmlResponse:XML;
var xmlURLReq:URLRequest=new URLRequest("saveTheme.php");
xmlURLReq.data=xml;// tu znajduje sie moj xml
xmlURLReq.contentType="text/xml";
xmlURLReq.method=URLRequestMethod.POST;
var xmlSendLoad:URLLoader = new URLLoader();
xmlSendLoad.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
xmlSendLoad.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
xmlSendLoad.load(xmlURLReq);
function onComplete(evt:Event):void {
...
}
function onIOError(evt:IOErrorEvent):void {
...
}
}
save_project.addEventListener(MouseEvent.MOUSE_DOWN, SendToURLExample);
jednak ten xml we flaszu "zajmuje" całe xmlURLReq.data a potrzebuje jeszcze wysłac nazwe katalogu do php
probowałem tak jak sie wysyła normalne zmienne naprzyklad stringi
function SendToURLExample(event:MouseEvent):void {
var url:String="saveTheme.php";
var variables:URLVariables = new URLVariables();
variables.kat="test"
variables.xml=xml.toString();
var request:URLRequest=new URLRequest(url);
request.data=variables;
request.method=URLRequestMethod.POST;
trace(variables);
try {
sendToURL(request);
} catch (e:Error) {
// handle error here
}
}
i php
<?php
$flaxml = $_POST['xml'];
$flakat = $_POST['kat'];
$fh = fopen("themes/".$flakat."/".$flakat.".xml", 'w') or
die("can't open file"); $xml ='<'.'?xml version="1.0" encoding="utf-8"?'.'>'. "\r\n" .$flaxml ;
$odp="wyslano dane \r\n".kat;
?>
jednak czy robie
variables.xml=xml.toString(); czy variables.xml=xml.toXMLString(); czy tylko variables.xml=xml
wynikiem jest zapis do xml ale to juz nie jest xml tylko xml zepsuty
<site name="site\">
<bg name=\"LAY1\" type=\"layout\">
<bg name=\"kolor0\" type=\"buildin\" source=\"AllFacesCOLOR\" width=\"stageWidth\" alpha=\"1\" height=\"stageHeight\" parameters=\"0xbfb297\"/>
<bg name=\"kolor1\" type=\"buildin\" so
jak zamienic $flaxml = $_POST['xml']; na xml spowrotem i zapisac by było ok
ok moge dołaczyc header do tego przesyłu
URLRequestHeader
jak go odczytac w php pozniej
var xmlURLReq:URLRequest=new URLRequest("saveTheme.php");
var header:URLRequestHeader
= new URLRequestHeader
("plik", "test");/*************************/ xmlURLReq.data=xml;
xmlURLReq.contentType="text/xml";
xmlURLReq.method=URLRequestMethod.POST;
request
.requestHeaders
.push
(header);/*************************/
mogłbym w tym headerze przesłac nazwe katalogu i tylko jak go odczytac w php
i czy nie popierniczy kodu tez