Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
newberry94005

Sending xml data to the server to overwrite current xml

Recommended Posts

I can't figure something out. I am trying to:

 

Simply stated, I have loaded an XML doc. Changed it within Flash. I then want to update the XML doc on the server. Then reload the XML back into Flash.

 

I have one main .xml document - "StudentXML.xml" (This is the file I want to overwrite with new info - it is also the file I read from with the application begins.)

 

And one main .php document - "index.php" (sorry for my crappy naming standards..)

 

Here is the PHP code I found (hoping it would do what I wanted) located in "index.php":

 

<?php
$filename = "StudentXML.xml";
$raw_xml = file_get_contents("php://input");
print $raw_xml;
$fp = fopen($filename, "w");
fwrite($fp, $raw_xml);
fclose($fp);
?>

 

Here is my data I want to change and see transfered to the server to overwrite the current XML Document. At this point, I have already loaded, accessed, and read my StudentXML.xml within Flash.

 

var newLogin:XML = <badge>eStudioLogin</badge>;
studentXML.id.(@number == studentID.toString()).allBadgeNames.prependChild(newLogin);
studentXML.id.(@number == studentID.toString()).badgesEarned = int(studentXML.id.(@number == studentID.toString()).badgesEarned) + 1;

 

So far, and this is not working, I have pieced together this lovely bit of code:

 

var requested:URLRequest = new URLRequest("www.mysite.com/index.php");
requested.data = studentXML; // This does trace the entire [i]edited[/i] XML document that is in Flash
requested.method = URLRequestMethod.POST;
var loader:XMLLoader = new XMLLoader(requested,{name:"StudentXML",onProgress:showProgress});
loader.load();

 

I know I am being dumb. It can't be this hard to transfer data and overwrite an existing xml document. Any help would truly be appreciated.

 

Thanks,

Adam

Link to post
Share on other sites

Sorry, I can't really do anything to trouble shoot what is happening on your server or in the php.

Can you confirm that requested.data is making it to your server?

Is the problem getting the data to the server or overwriting the xml?

 

Even with the answers to those questions, I don't know if I or anyone on this forum is going to be able to offer you tons of help.

 

What I would suggest is taking a few steps back and creating a system that

 

submits an URLRequest with very simple data attached like "myName = adam" to a script that will then return some pre-existing xml only if it receives the proper data. Work until you get that part working, then see if you can get the server to overwrite data for you and return some new xml. Do all of that without the GreenSock tools.

 

If you have trouble with any of that, I'm sure some folks on stackoverflow.com or a dedicated php or flash forum can help.

 

Once you have the roundtrip data service (submiting data, overwriting data, returning data) in place then you will be in a good place to tie in with XMLLoader, perhaps at that point we will be better able to service why XMLLoader is not working but a regular as3 loader is.

 

Again, sorry that I can't easily decipher the php or suggest a more immediately helpful course of action.

 

-c

Link to post
Share on other sites

Thanks Carl!

 

That is very good advice. I will create a new app that has the sole purpose of transferring the small amount of data you recommended.

 

To answer your questions. No, I can't tell if the request.data is making it to the server. (I don't know if the way I am doing it is even communicating to the server???)

 

Unfortunately, I am VERY new to php and xml, and somewhat new to as3.

 

I don't even know if what I am trying is the right way to send and receive data. I am comfortable loading the XML document from the server. Other than that, I am lost in the world of send and receive. Looks like, I still have a long way to go....

 

Thanks again for your reply and I will try and post back if I am able to get this working.

 

Adam

  • Like 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×