简体   繁体   English

如何在 flex web 应用程序中执行文件读写操作?

[英]How to perform file read write operation in flex web application?

How to perform file read write operation on server in flex web application?如何在 flex web 应用程序中对服务器执行文件读写操作? Please guide.请指导。

Your help would be appreciated.您的帮助将不胜感激。

Well it all depends on.好吧,这一切都取决于。 Fileread operation is possible in a web application, but filewrite has to be solved with a server side language, like php.在 web 应用程序中可以进行文件读取操作,但文件写入必须使用服务器端语言解决,例如 php。

Generally, for reading you can use URLStream , this reads a file into a stream.通常,您可以使用URLStream进行读取,这会将文件读入 stream。 The easiest usage is:最简单的用法是:

var ldr:URLStream = new URLStream();
ldr.addEventListener("complete", ldrDone);
ldr.load(new URLRequest(URL_OF_YOUR_FILE));

function ldrDone(evt:*):void
{
     //store the file in a bytearray
     var bytes:ByteArray = new ByteArray();
     evt.target.readBytes(bytes);
     trace(bytes);
}

To write files, use php or whatever script.要写入文件,请使用 php 或任何脚本。 How to write this and what to include in the code really depend on your project.如何编写这个以及在代码中包含什么实际上取决于您的项目。

For flash-related file reading (like loading a swf, or supported image formats, mostly jpg, gif, png natively), use the Loader class.对于与 Flash 相关的文件读取(如加载 swf 或支持的图像格式,主要是 jpg、gif、png),请使用加载程序class。

For text files and xmls, use the URLLoader class.对于文本文件和 xml,请使用URLLoader class。

If you have more questions, feel free to ask.如果您有更多问题,请随时提问。

Depends completely on your backend server technology.完全取决于您的后端服务器技术。 PHP, Java, ASP.NET? PHP、Java、ASP.NET? Either way you use the same server side documentation tutorial on your server side as handling a file upload.无论哪种方式,您都可以在服务器端使用与处理文件上传相同的服务器端文档教程。 On the flex side FileReference.upload does the trick.在 flex 方面 FileReference.upload 可以解决问题。

See: http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_7.html请参阅: http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_7.ZFC35FDC70D5FC69D269883A822C7A53E

http://www.flex888.com/296/9-flex-file-upload-examples-visited.html http://www.flex888.com/296/9-flex-file-upload-examples-visited.html

http://www.adobe.com/devnet/flex/articles/file_upload.html http://www.adobe.com/devnet/flex/articles/file_upload.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM