开发者

Write ActionScript Value to File Via php

开发者 https://www.devze.com 2023-02-22 06:51 出处:网络
I have some XML I\'ve edited in ActionScript that I would like to save locally via php. My php script (called writeFile.php) is the following:

I have some XML I've edited in ActionScript that I would like to save locally via php. My php script (called writeFile.php) is the following:

<?php
  $variable = $_POST['data'];
  $file = "tmp.xml";
  $fh = fopen($file, 'w');
  fwrite($fh, $variable);
  fclose($fh);
  echo "Done!";
?>

My ActionScript is the following:

var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("writeFile.php");
var vars:URLVariables = new URLVariables();
vars.data = xml.toXMLString();
request.data = vars;
request.method =开发者_如何转开发 URLRequestMethod.POST;
loader.addEventListener(Event.COMPLETE,onComplete);
loader.load(request);

However, no file is being created, and thus obviously nothing is being written to it.


Make sure that you have write permission for that directory on the server. And in the onComplete function look for the server response to make sure you're seeing "Done!"

0

精彩评论

暂无评论...
验证码 换一张
取 消