Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 397

Programming actionscript 3.0
Table of Contents

Advertisement

(actual file data,,,)
------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
Content-Disposition: form-data; name="Upload"
Submit Query
------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7--
Uploading files to a server
To upload files to a server, first call the
files. Next, when the
transferred to the server. If the user selected multiple files using the
FileReferenceList.browse()
FileReferenceList.fileList
upload each file individually.
Using the
FileReference.browse()
a user to upload multiple files, you must use the
By default, the OS file picker dialog box allows users to pick any file type from the local
computer, although developers can specify one or more custom file type filters by using the
FileFilter class and passing an array of file filter instances to the
var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif,
*.png)", "*.jpg; *.jpeg; *.gif; *.png");
var textTypes:FileFilter = new FileFilter("Text Files (*.txt, *.rtf)",
"*.txt; *.rtf");
var allTypes:Array = new Array(imageTypes, textTypes);
var fileRef:FileReference = new FileReference();
fileRef.browse(allTypes);
When the user has selected the files and clicked the Open button in the OS file picker, the
event is dispatched. If the
Event.SELECT
select a file to upload, the following code is needed to send the file to a web server:
var fileRef:FileReference = new FileReference();
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
try
{
var success:Boolean = fileRef.browse();
}
catch (error:Error)
{
trace("Unable to browse for files.");
}
function selectHandler(event:Event):void
browse()
FileReference.upload()
method, Flash Player creates an array of selected files called
. You can then use the
method allows you to upload single files only. To allow
FileReference.browse()
method to allow a user to select one or more
method is called, the selected file will be
FileReference.upload()
FileReferenceList.browse()
browse()
Working with file upload and download
method to
method.
method:
method was used to
397

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents