ファイル名で満たされたデータグリッドを持つ Flash アプリケーションがあり、ユーザーがそのグリッドから複数のファイルをチェックして、ローカル ドライブにダウンロードできるようにしたいと考えています。ファイルはデータベースの blob フィールドに保存され、php ro を使用してそれらを取得します。URLLoader と FileReference を使用してファイルをダウンロードしようとしていますが、機能していません。コードは次のとおりです。
private function downloadSelected():void {
var dp:Object=dg.dataProvider;
var cursor:IViewCursor=dp.createCursor();
while( !cursor.afterLast )
{
//Alert.show(cursor.current.IsChecked.toString());
if (cursor.current.IsChecked.toString()=="true") {
//myAmostras.push(cursor.current.CodBarras.toString());
//nenhumaAmostra=false;
var u:URLRequest= new URLRequest;
var variables:URLVariables = new URLVariables();
variables.amostras = cursor.current.CodBarras.toString();
variables.disposition="attach";
u = new URLRequest("savereports.php");
u.method = URLRequestMethod.POST;
u.data=variables;
pdfloader = new URLLoader();
//pdfloader.dataFormat=URLLoaderDataFormat.BINARY;
pdfloader.addEventListener(Event.COMPLETE, completeHandler,false,0,true);
pdfloader.addEventListener(IOErrorEvent.IO_ERROR, downloadError);
try {
pdfloader.load(u);
} catch (error:Error) {
Alert.show("Unable to load requested document.");
}
}
cursor.moveNext();
}
}
private function downloadError(event:Event):void {
Alert.show("Error loading file");
}
private function completeHandler(event:Event):void {
var myFileReference:FileReference = new FileReference();
myFileReference.save(event.target.data);
}
誰でもこれについて私を助けることができますか?