1

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

有关详细信息,请参阅通过 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 字符串,其中包含文件大小、ID 号等详细信息。

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

4

1 回答 1

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);
}
于 2012-06-06T12:58:29.687 回答