加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex 怎么检测文件大小.

发布时间:2020-12-15 03:34:25 所属栏目:百科 来源:网络整理
导读:在浏览器下面.ie很难检测文件大小. 好不容易 img 有个 函数可以..ie7 下面又不可以了.. 没有办法.试验下 flex 到是大小出来了.. ? ?xml version="1.0" encoding="utf-8"?mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" mx:Script ![CD

在浏览器下面.ie很难检测文件大小.
好不容易 img 有个 函数可以..ie7 下面又不可以了..

没有办法.试验下 flex 到是大小出来了..

?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
 xmlns="*" >
 
 <mx:Script>
  <![CDATA[
   import flash.events.*;
   import flash.net.FileReference;
   import flash.net.URLRequest;
   import mx.controls.Alert;

   private var currentAction:String;
         private var uploadURL:URLRequest;
         private var file:FileReference;
        
         private var fileName:String;

    private function init() : void{
                file = new FileReference();
            }
           
         public function FileReference_browse() : void {
          currentAction = "upload";
             uploadURL = new URLRequest();
             file = new FileReference();
             configureListeners(file);
             file.browse();
         }

         private function configureListeners(dispatcher:IEventDispatcher):void {
             dispatcher.addEventListener(Event.SELECT,selectHandler);
         }
 
         private function selectHandler(event:Event):void {
             var file:FileReference = FileReference(event.target);
              Alert.show(file.size+"");

         }

  ]]>
 </mx:Script>

 <mx:Panel width="100%" height="100%">
  <mx:VBox width="100%" horizontalAlign="center">
   <mx:Label text="Click the below button to select a file which you want to upload!" />
   <mx:Button label="Upload" click="FileReference_browse()" />
  </mx:VBox>
 </mx:Panel>
 
</mx:Application>
?

下面就是考虑如何和js进行交互了.

通过js得到file的长度.然后进行上传..然而也可以

用flex编写一个上传组件.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读