如何检索文件上传通过动作后JSON结果 [英] How to retrieve JSON result after file upload via actionscript
问题描述
我知道如何使用要上传的文件动作脚本
I know how to upload a file using action script
请参阅<一href="http://stackoverflow.com/questions/10772616/upload-a-zip-file-using-http-post-via-actionscript-3-0">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?
推荐答案
在<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html#event%3auploadCompleteData"相对=nofollow> 的FileReference
文档,你需要一个处理程序添加到您的的FileReference
实例在 uploadCompleteData code>事件:
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);
}
这篇关于如何检索文件上传通过动作后JSON结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!