如何检索通过ActionScript文件上传后JSON结果(How to retrieve JSON

2019-10-16 19:29发布

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

请参见通过ActionScript 3.0上传使用HTTP POST一个zip文件的详细信息。

代码复制在这里:

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字符串

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

Answer 1:

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


文章来源: How to retrieve JSON result after file upload via actionscript