如何检索文件上传通过动作后JSON结果文件上传、动作、结果、JSON

2023-09-08 11:45:12 作者:相关可爱的六个字>>

我知道如何使用要上传的文件动作脚本

I know how to upload a file using action script

请参阅upload通过ActionScript 3.0 了解详细信息,利用HTTP POST一个zip文件。

See upload a zip file using HTTP POST via actionscript 3.0 for details.

code在这里复制:

Code replicated here:

var urlRequest:URLRequest = new URLRequest(PUBLISH_ZIP_FILE_URL);
// set to method=POST
urlRequest.method = URLRequestMethod.POST;

var params:URLVariables = new URLVariables();

params['data[File][title]'] = 'Title1';
params['data[File][description]'] = 'desc';

// this is where we include those non file params and data
urlRequest.data = params;


// now we upload the file
// this is how we set the form field expected for the file upload
file.upload(urlRequest, "data[File][filename]");

Web应用程序负责受理文件上传将返回包含详细信息,例如文件大小,身份证号码,等一个JSON字符串。

The web app responsible for accepting the file upload will return a JSON string containing details such as file size, id number, etc.

我如何访问我的动作此JSON结果字符串?

How do I access this JSON result string in my actionscript?

推荐答案

的FileReference 文档,你需要一个处理程序添加到您的的FileReference 实例在 uploadCompleteData 事件:

import flash.events.*;

// now we upload the file
// this is how we set the form field expected for the file upload
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadCompleteDataHandler);
file.upload(urlRequest, "data[File][filename]");

private function uploadCompleteDataHandler(event:DataEvent):void  
{
     trace("uploadCompleteData data: " + event.data);
}