644 Working with External Data
About file uploading and downloading
The FileReference class lets you add the ability to upload and download files between a client
and server. Your users can upload or download files between their computer and a server.
Users are prompted to select a file to upload or a location for download in a dialog box (such
as the Open dialog box on the Windows operating system).
Each FileReference object that you create with ActionScript refers to a single file on the user’s
hard disk. The object has properties that contain information about the file’s size, type, name,
creation date, and modification date. On the Macintosh, there is also a property for the file’s
creator type.
You can create an instance of the FileReference class in two ways. You can use the following
new operator:
import flash.net.FileReference;
var myFileReference:FileReference = new FileReference();
Or, you can call the FileReferenceList.browse() method, which opens a dialog box on
the user’s system to prompt the user to select a file to upload and then creates an array of
FileReference objects if the user selects one or more files successfully. Each FileReference
object represents a file selected by the user from the dialog box. A FileReference object does
not contain any data in the FileReference properties (such as
name, size, or
modificationDate) until the FileReference.browse() method or
FileReferenceList.browse() method has been called and the user has selected a file from
the file picker or until the
FileReference.download() method has been used to select a file
from the file picker.
After a successful call to the browse() method, you call FileReference.upload() to upload
one file at a time.
NOTE
FileReference.browse() lets the user select a single file. FileReferenceList.browse() lets
the user select multiple files.