代码之家  ›  专栏  ›  技术社区  ›  limscoder

如何绕过闪存错误2176

  •  2
  • limscoder  · 技术社区  · 15 年前

    在我的flex应用程序中,用户需要能够上传和下载内容。但是,此内容受访问限制,我需要在允许上载/下载之前进行权限检查。用户单击一个链接,然后使用FileReference类选择一个文件。FileReference类不附加cookie信息,因此无法使用会话。

    我想实现一个两步的过程,其中客户端首先ping服务器以获取一次性使用令牌,然后以一次性使用令牌作为参数进行上载或下载。然而,这个计划被错误2176所挫败,这显然是对FP10的一个安全修复,只允许在mouseEvent传播期间触发上传/下载。不管怎么说?

    1 回复  |  直到 14 年前
        1
  •  3
  •   ravinikam    14 年前

    我为此找到了工作 here.

     <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
                    layout="absolute" 
                    minWidth="955" minHeight="600"
                    creationComplete="creationCompleteHandler(event)">
        <mx:Script>
            <![CDATA[
                import mx.controls.Alert;
                import mx.events.CloseEvent;
                import mx.events.FlexEvent;
    
                protected function creationCompleteHandler(event:FlexEvent):void
                {
                    Alert.show("Now you can save the file!", "Test", Alert.OK|Alert.CANCEL, null, closeHandler);
                }
    
                protected function closeHandler( event:CloseEvent ):void
                {
                    var fileReference :FileReference;
    
                    if ( event.detail == Alert.OK )
                    {
                        fileReference = new FileReference();
                        fileReference.save("http://www.bogdanmanate.com", "test.txt");
                    }
                }
            ]]>
        </mx:Script>
    
    </mx:Application>
    
    推荐文章