Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 403

Programming actionscript 3.0
Table of Contents

Advertisement

The following code demonstrates the ColdFusion script, download.cfm, that downloads one
of two files from the server, depending on the value of a URL variable:
<cfparam name="URL.id" default="1" />
<cfswitch expression="#URL.id#">
<cfcase value="2">
<cfcontent type="text/plain" file="#ExpandPath('two.txt')#"
deletefile="No" />
</cfcase>
<cfdefaultcase>
<cfcontent type="text/plain" file="#ExpandPath('one.txt')#"
deletefile="No" />
</cfdefaultcase>
</cfswitch>
FileReferenceList class
The FileReferenceList class lets the user select one or more files to upload to a server-side
script. The file upload is handled by the
called on each file that the user selects.
The following code creates two FileFilter objects (
them in an array to the
system file dialog box to display two possible filters for file types.
var imageFilter:FileFilter = new FileFilter("Image Files (*.jpg, *.jpeg,
*.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
var textFilter:FileFilter = new FileFilter("Text Files (*.txt, *.rtf)",
"*.txt; *.rtf");
var fileRefList:FileReferenceList = new FileReferenceList();
try
{
var success:Boolean = fileRefList.browse(new Array(imageFilter,
textFilter));
}
catch (error:Error)
{
trace("Unable to browse for files.");
}
Allowing the user to select and upload one or more files by using the FileReferenceList class is
the same as using
FileReference.browse()
allows you to select more than one file. Uploading multiple files requires you to upload each
of the selected files by using
var fileRefList:FileReferenceList = new FileReferenceList();
fileRefList.addEventListener(Event.SELECT, selectHandler);
fileRefList.browse();
function selectHandler(event:Event):void
FileReference.upload()
FileReferenceList.browse()
FileReference.upload()
and
imageFilter
method. This causes the operating
to select files, although the FileReferenceList
, as the following code shows:
Working with file upload and download
method, which must be
) and passes
textFilter
403

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents