Chapter 25. Managing File Uploads and Downloads

Introduction

In this chapter

  • Uploading files

  • Downloading files

File upload and download is important for many applications. By enabling users to upload files, you allow them to contribute content such as images, audio, and video, which is crucial in a Web 2.0 world. By adding file download features to an application you allow users to save content locally on their computers. Flash Player supports both file upload and download using the flash.net.FileReference and flash.net.FileReferenceList classes.

Introducing FileReference

The flash.net.FileReference class enables users to browse for a file to upload or select a location to save a downloaded file to using a system dialog box. The flash.net.FileReferenceList class lets users select one or more files to upload. In this chapter, you learn to work with the FileReference class and the FileReferenceList class.

Except when returned from a FileReferenceList, FileReference objects are constructed using the constructor in a new statement. The constructor does not require any parameters:

var fileToUpload:FileReference = new FileReference();

Optionally, if you want the user to be able to select many files at once, you can use a FileReferenceList object. Like FileReference, the FileReferenceList constructor requires no parameters:

var fileListToUpload:FileReferenceList = new FileReferenceList();

Uploading Files

The following sections explain how to upload files using FileReference and FileReferenceList ...

Get ActionScript™ 3.0 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.