Working With File Upload And Download - Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual

Programming actionscript 3.0
Table of Contents

Advertisement

FileReference class
The FileReference class allows you to upload and download files between a user's computer
and a server. An operating system dialog box prompts the user to select a file to upload or a
location for download. Each FileReference object refers to a single file on the user's disk and
has properties that contain information about the file's size, type, name, creation date,
modification date, and creator.
FileReference instances can be created in two ways:
When you use the
var myFileReference:FileReference = new FileReference();
When you call
FileReferenceList.browse()
objects.
For uploading and downloading operations, a SWF file can access files only within its own
domain, including any domains specified by a cross-domain policy file. You need to put a
policy file on the file server if the SWF file initiating the upload or download doesn't come
from the same domain as the file server.
You can only perform one browse() or download() action at a time, because only one
dialog box can be open at any point.
The server script that handles the file upload should expect an HTTP
following elements:
with a value of
Content-Type
Content-Disposition
set to the name of the original file. You can specify a custom
value for the
uploadDataFieldName
method.
The binary contents of the file.
Here is a sample HTTP
POST /handler.asp HTTP/1.1
Accept: text/*
Content-Type: multipart/form-data;
boundary=----------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
User-Agent: Shockwave Flash
Host: www.mydomain.com
Content-Length: 421
Connection: Keep-Alive
Cache-Control: no-cache
operator with the FileReference constructor, as in the following:
new
multipart/form-data.
with a
attribute set to "
name
parameter in the
request:
POST
, which creates an array of FileReference
POST
" and a
Filedata
attribute by passing a
name
FileReference.upload()

Working with file upload and download

request with the
attribute
filename
395

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents