Flash actionscript - 在服务器上保存文本文件 [英] 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.
推荐答案
使用flash.net.URLRequest
将数据发送到服务器上的脚本,该脚本将数据保存到文件中.
Use flash.net.URLRequest
to send the data to a script on the server that saves the data to a file.
Flash Player 无法直接访问服务器,因为它在客户端计算机上运行,因此您需要这样做.
The Flash Player cannot access the server directly, as it runs on the client computer, so you need to do it that way.
// 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 );
这篇关于Flash actionscript - 在服务器上保存文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!