User Guide

398 Networking and Communication
{
var request:URLRequest = new URLRequest("http://www.[yourdomain].com/
fileUploadScript.cfm")
try
{
fileRef.upload(request);
}
catch (error:Error)
{
trace("Unable to upload file.");
}
}
function completeHandler(event:Event):void
{
trace("uploaded");
}
When you attempt to upload a file using the FileReference.upload() method, any of the
following events may be dispatched:
Event.OPEN: Dispatched when an upload operation starts.
ProgressEvent.PROGRESS: Dispatched periodically during the file upload operation.
Event.COMPLETE: Dispatched when the file upload operation completes successfully.
SecurityErrorEvent.SECURITY_ERROR: Dispatched when an upload fails because of a
security violation.
HTTPStatusEvent.HTTP_STATUS: Dispatched when an upload fails because of an HTTP
error.
IOErrorEvent.IO_ERROR: Dispatched if the upload fails because of any of the following
reasons:
An input/output error occurred while Flash Player is reading, writing, or transmitting
the file.
The SWF tried to upload a file to a server that requires authentication (such as a user
name and password). During upload, Flash Player does not provide a means for users
to enter passwords.
TIP
You can send data to the server with the FileReference.upload() method by using the
URLRequest.method and URLRequest.data properties to send variables using the POST or
GET methods.