zozo
zozo

Reputation: 8602

Flash actionscript - save a text file on server

Good day to all. I have a little problem.

Can anyone tell me or give a link or something on how to save a text file on the server with some data a user inserted?

I need to do this: I have a text box and after pressing enter I need to create/append a file with a log of what a user entered. I have created the box, add listener but I don't know how to create the file. Thank you for help.

Upvotes: 1

Views: 3061

Answers (1)

poke
poke

Reputation: 388273

Use flash.net.URLRequest to send the data to a script on the server that saves the data to a file.

The Flash Player cannot access the server directly, as it runs on the client computer, so you need to do it that way.

Example

// prepare the data to send, for example in a URLVariables object.
var vars:URLVariables = new URLVariables();
vars.userId = 1234;
vars.enteredData = 'Hello World';

// construct the URL request
var req:URLRequest = new URLRequest( 'myscript.php' );
req.method = URLRequestMethod.POST;
req.data = vars;

// open the URL request (you can for example listen to events and
// evaluate the script's response data etc)
var loader:URLLoader = new URLLoader( req );

Upvotes: 4

Related Questions