Flash actionscript - save a text file on server

回眸只為那壹抹淺笑 提交于 2019-12-06 12:27:03

问题


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.


回答1:


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 );


来源:https://stackoverflow.com/questions/4992140/flash-actionscript-save-a-text-file-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!