Accessibility

Table of Contents

Uploading files to a server from an Adobe AIR application

Handling multiple file uploads

When a FileReferenceList is called as opposed to the single file occurrence FileReference, the following code shows an example of how the selected files can be referenced:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="startApplication();">
   
    <mx:Script>       
    <![CDATA[           
    private var fileRefList:FileReferenceList = new FileReferenceList();
           
    private function startApplication():void {
               
    fileRefList.browse();
    fileRefList.addEventListener(Event.SELECT,selectHandler);           
    }
           
    private function selectHandler(event:Event):void {               
        for(var i:uint = 0;i<fileRefList.fileList.length;i++) {                   
            var fileRef:FileReference = FileReference(fileRefList.fileList[i]);                   
            trace(fileRef.name);               
        }           
    }       
    ]]>   
    </mx:Script>
</mx:WindowedApplication>

The FileReferenceList class offers a fileList property of data type Array, which itself contains a list of FileReference objects of each of the selected files. This Array can be looped with each file being uploaded in succession.