2

我正在使用 Flash 运行时(Flash 播放器 10)。我有一个 flv 编码的字节数组,我需要将它发送到服务器(简单的 php,没有 FMS 或套接字服务器)并保存在那里。我可以使用 urlLoader 并发布所有内容,但我不会获得进度百分比,所以我尝试使用如下文件引用保存它:

var url_ref:URLRequest = new URLRequest("save_vid.php");    
url_ref.contentType = "multipart/form-data; boundary="+getBoundary();
url_ref.data = _baFlvEncoder.byteArray;
url_ref.method = URLRequestMethod.POST;

var upfileRef:FileReference = new FileReference();
upfileRef.addEventListener(ProgressEvent.PROGRESS, onUploadProgress);
upfileRef.addEventListener(Event.COMPLETE, videoUploadComplete);
upfileRef.upload(url_ref);

但是当我尝试这个时,我收到一个错误:

Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.

知道我该怎么做吗?

4

1 回答 1

2

尝试这个:

var vars :URLVariables = new URLVariables();
vars.bytearray  = _baFlvEncoder.byteArray;

var req :URLRequest = new URLRequest("save_vid.php");
req.method = URLRequestMethod.POST;
req.data = vars;

var ldr :URLLoader = new URLLoader();
ldr.addEventListener( Event.COMPLETE, onLoaded );
ldr.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
ldr.addEventListener( ProgressEvent.PROGRESS, onProgress );
ldr.load( req );

function onProgress( e:ProgressEvent ):void 
{           
    trace( "Progress: " + e.bytesLoaded / e.bytesTotal );
}

在 PHP 中

$bytearray = $_POST['bytearray']
于 2012-08-16T12:16:23.227 回答