Properties | Events | Methods |
Object
Player version: | Flash Player 8 |
FileReference instances are created in two ways:
new
operator with the FileReference constructor: var myFileReference = new FileReference();
FileReferenceList.browse()
, which creates an array of FileReference objectsDuring an upload operation, all of the properties of a FileReference object are populated by calls to FileReference.browse()
or FileReferenceList.browse()
. During a download operation, the name
property is populated when onSelect
has been invoked; all other properties are populated when onComplete
has been invoked.
The browse()
method opens an operating-system dialog box which prompts the user to select any local file for upload. The FileReference.browse()
method lets the user select a single file; the FileReferenceList.browse()
method lets the user select multiple files. After a successful call to the browse()
method, call the FileReference.upload()
method to upload one file at a time. The FileReference.download()
method prompts the user for a location to save the file and initiates downloading from a remote URL.
The FileReference and FileReferenceList classes do not let you set the default file location for the dialog box generated by browse()
and download()
calls. The default location shown in the dialog box is the most recently browsed folder, if that location can be determined, or the desktop. The classes do not allow you to read from or write to the transferred file. They do not allow the SWF file that initiated the upload or download to access the uploaded or downloaded file or the file's location on the user's disk.
The FileReference and FileReferenceList classes also do not provide methods for authentication. With servers that require authentication, you can download files with the Flash Player browser plug-in, but uploading (on all players) and downloading (on the stand-alone or external player) fails. Use FileReference event listeners to ascertain whether operations have successfully completed and to handle errors.
For uploading and downloading operations, a SWF file can access files only within its own domain, including any domains that are specified by a cross-domain policy file. If the SWF that is initiating the upload or download doesn't come from the same domain as the file server, you must put a policy file on the file server.
While calls to the FileReference.browse()
, FileReferenceList.browse()
, or FileReference.download()
methods are executing, SWF file playback pauses on the following platforms: the Flash Player plug-in for Mac OS X, the external Flash Player for Macintosh, and the stand-alone player for Mac OS X 10.1 and earlier. The SWF file continues to run in all players for Windows and in the stand-alone player for Macintosh on Mac OS X 10.2 and later.
import flash.net.FileReference; var allTypes:Array = new Array(); var imageTypes:Object = new Object(); imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)"; imageTypes.extension = "*.jpg; *.jpeg; *.gif; *.png"; allTypes.push(imageTypes); var textTypes:Object = new Object(); textTypes.description = "Text Files (*.txt, *.rtf)"; textTypes.extension = "*.txt;*.rtf"; allTypes.push(textTypes); var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("onSelect: " + file.name); if(!file.upload("http://www.yourdomain.com/yourUploadHandlerScript.cfm")) { trace("Upload dialog failed to open."); } } listener.onCancel = function(file:FileReference):Void { trace("onCancel"); } listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); } listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); } listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } listener.onHTTPError = function(file:FileReference):Void { trace("onHTTPError: " + file.name); } listener.onIOError = function(file:FileReference):Void { trace("onIOError: " + file.name); } listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse(allTypes);
FileReferenceList |
Property Summary | |
| creationDate : Date [read-only]The creation date of the file on the local disk. |
| creator : String [read-only]The Macintosh creator type of the file. |
| modificationDate : Date [read-only]The date that the file on the local disk was last modified. |
| name : String [read-only]The name of the file on the local disk. |
| size : Number [read-only]The size of the file on the local disk, in bytes. |
| type : String [read-only]The file type. |
Properties inherited from class Object |
__proto__, __resolve, constructor, prototype |
Event Summary | |
onCancel = function(fileRef:FileReference) {}
Invoked when the user dismisses the file-browsing dialog box. |
|
onComplete = function(fileRef:FileReference) {}
Invoked when the upload or download operation has successfully completed. |
|
onHTTPError = function(fileRef:FileReference, httpError:Number) {}
Invoked when an upload fails because of an HTTP error. |
|
onIOError = function(fileRef:FileReference) {}
Invoked when an input/output error occurs. |
|
onOpen = function(fileRef:FileReference) {}
Invoked when an upload or download operation starts. |
|
onProgress = function(fileRef:FileReference, bytesLoaded:Number, bytesTotal:Number) {}
Invoked periodically during the file upload or download operation. |
|
onSecurityError = function(fileRef:FileReference, errorString:String) {}
Invoked when an upload or download fails because of a security error. |
|
onSelect = function(fileRef:FileReference) {}
Invoked when the user selects a file to upload or download from the file-browsing dialog box. |
Constructor Summary | |
FileReference()
Creates a new FileReference object. |
Method Summary | |
| addListener(listener:Object) : Void
Registers an object to receive notification when a FileReference event listener is invoked. |
| browse([typelist:Array]) : Boolean
Displays a file-browsing dialog box in which the user can select a local file to upload. |
| cancel() : Void
Cancels any ongoing upload or download operation on this FileReference object. |
| download(url:String, [defaultFileName:String]) : Boolean
Displays a dialog box in which the user can download a file from a remote server. |
| removeListener(listener:Object) : Boolean
Removes an object from the list of objects that receive event notification messages. |
| upload(url:String) : Boolean
Starts the upload of a file selected by a user to a remote server. |
Methods inherited from class Object |
addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch |
Property Detail |
public creationDate : Date
[read-only]
Player version: | Flash Player 8 |
null
.
Example
import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("creationDate: " + file.creationDate); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
FileReference.browse() |
public creator : String
[read-only]
Player version: | Flash Player 8 |
null
. If the FileReference object has not been populated, a call to get the value of this property returns null
.
Example
import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("creator: " + file.creator); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
FileReference.browse() |
public modificationDate : Date
[read-only]
Player version: | Flash Player 8 |
null
.
Example
modificationDate
of a file selected by the user. import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("modificationDate: " + file.modificationDate); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
FileReference.browse() |
public name : String
[read-only]
Player version: | Flash Player 8 |
null
. All the properties of a FileReference object are populated by calling browse()
. Unlike other FileReference properties, if you call download()
, the name
property is populated when onSelect
is invoked.
import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("name: " + file.name); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
FileReference.browse() |
public size : Number
[read-only]
Player version: | Flash Player 8 |
null
.
Example
import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("size: " + file.size + " bytes"); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
FileReference.browse() |
public type : String
[read-only]
Player version: | Flash Player 8 |
null
.
Example
import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("type: " + file.type); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
FileReference.browse() |
Event Detail |
public onCancel = function(fileRef:FileReference) {}
Player version: | Flash Player 8 |
FileReference.browse()
, FileReferenceList.browse()
, or FileReference.download()
.
Parameters
fileRef:FileReference — The FileReference object that initiated the operation. |
import flash.net.FileReference; var listener:Object = new Object(); listener.onCancel = function(file:FileReference):Void { trace("onCancel"); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; if(!fileRef.download(url, "FlashPlatform.pdf")) { trace("dialog box failed to open."); }
public onComplete = function(fileRef:FileReference) {}
Player version: | Flash Player 8 |
fileRef:FileReference — The FileReference object that initiated the operation. |
onComplete
event is triggered. import flash.net.FileReference; var listener:Object = new Object(); listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf");
public onHTTPError = function(fileRef:FileReference, httpError:Number) {}
Player version: | Flash Player 8 |
Because of the way that Flash Player relies on the browser stack during file download, this error is not applicable for download failures. If a download fails because of an HTTP error, the error is reported as an I/O error.
ParametersfileRef:FileReference — The File Reference object that initiated the operation. |
|
httpError:Number — The HTTP error that caused this upload to fail. For example, an httpError of 404 indicates that a page is not found. HTTP error values can be found in sections 10.4 and 10.5 of the HTTP specification at ftp://ftp.isi.edu/in-notes/rfc2616.txt. |
onHttpError
. This listener is triggered only if the upload fails because of an HTTP error. import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("onSelect: " + file.name); if(!file.upload("http://www.yourdomain.com/yourUploadHandlerScript.cfm")) { trace("Upload dialog failed to open."); } } listener.onCancel = function(file:FileReference):Void { trace("onCancel"); } listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); } listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); } listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } listener.onHTTPError = function(file:FileReference):Void { trace("onHTTPError: " + file.name); } listener.onIOError = function(file:FileReference):Void { trace("onIOError: " + file.name); } listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
public onIOError = function(fileRef:FileReference) {}
Player version: | Flash Player 8 |
This listener is invoked when the upload or download fails for any of the following reasons:
url
parameter in upload()
contains an invalid protocol. Valid protocols are HTTP and HTTPS.fileRef:FileReference — The FileReference object that initiated the operation. |
onIOError
event is triggered. For simplicity, none of the other event listeners are included in this example. import flash.net.FileReference; var listener:Object = new Object(); listener.onIOError = function(file:FileReference):Void { trace("onIOError"); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.download("http://www.macromedia.com/NonExistentFile.pdf", "NonExistentFile.pdf");
public onOpen = function(fileRef:FileReference) {}
Player version: | Flash Player 8 |
fileRef:FileReference — The FileReference object that initiated the operation. |
onOpen
event is triggered. import flash.net.FileReference; var listener:Object = new Object(); listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf");
public onProgress = function(fileRef:FileReference, bytesLoaded:Number, bytesTotal:Number) {}
Player version: | Flash Player 8 |
onProgress
listener is invoked while the Flash Player transmits bytes to a server, and it is periodically invoked during the transmission, even if the transmission is ultimately not successful. To determine if and when the file transmission is successful and complete, use onComplete
. In some cases, onProgress
listeners are not invoked; for example, if the file being transmitted is very small, or if the upload or download happens very quickly.
File upload progress cannot be determined on Macintosh platforms earlier than OS X 10.3. The onProgress
event is called during the upload operation, but the value of the bytesLoaded
parameter is -1, indicating that the progress cannot be determined.
fileRef:FileReference — The FileReference object that initiated the operation. |
|
bytesLoaded:Number — The number of bytes transmitted so far. |
|
bytesTotal:Number — The total size of the file to be transmitted, in bytes. If the size cannot be determined, the value is -1. |
onProgress
event listener. import flash.net.FileReference; var listener:Object = new Object(); listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress: " + file.name + " with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf");
FileReference.onComplete |
public onSecurityError = function(fileRef:FileReference, errorString:String) {}
Player version: | Flash Player 8 |
fileRef:FileReference — The FileReference object that initiated the operation. |
|
errorString:String — Describes the error that caused onSecurityError to be called. The value is "securitySandboxError". |
onSecurityError
. The onSecurityError
listener is triggered only if the upload fails because of a security error. import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("onSelect: " + file.name); if(!file.upload("http://www.yourdomain.com/yourUploadHandlerScript.cfm")) { trace("Upload dialog failed to open."); } } listener.onCancel = function(file:FileReference):Void { trace("onCancel"); } listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); } listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); } listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } listener.onHTTPError = function(file:FileReference):Void { trace("onHTTPError: " + file.name); } listener.onIOError = function(file:FileReference):Void { trace("onIOError: " + file.name); } listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
public onSelect = function(fileRef:FileReference) {}
Player version: | Flash Player 8 |
FileReference.browse()
, FileReferenceList.browse()
, or FileReference.download()
.) When the user selects a file and confirms the operation (for example, by clicking OK), the properties of the FileReference object are populated. The onSelect
listener works slightly differently depending on what method invokes it. When onSelect
is invoked after a browse()
call, Flash Player can read all of the FileReference object's properties, because the file selected by the user is on the local file system. When onSelect
is invoked after a download()
call, Flash Player can read only the name
property, because the file hasn't yet been downloaded to the local file system at the moment onSelect
is invoked. When the file has been downloaded and onComplete
invoked, then Flash Player can read all other properties of the FileReference object.
fileRef:FileReference — The FileReference object that initiated the operation. |
onSelect
event listener. import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("onSelect: " + file.name); if(!file.upload("http://www.yourdomain.com/yourUploadHandlerScript.cfm")) { trace("Upload dialog failed to open."); } } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
Constructor Detail |
public FileReference()
Player version: | Flash Player 8 |
import flash.net.FileReference; var listener:Object = new Object(); listener.onComplete = function(file:FileReference) { trace("onComplete : " + file.name); } var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.download(url, "FlashPlatform.pdf");
FileReference.browse() |
Method Detail |
public addListener(listener:Object) : Void
Player version: | Flash Player 8 |
listener:Object — An object that listens for a callback notification from the FileReference event listeners. |
import flash.net.FileReference; var listener:Object = new Object(); listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); } listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf");
public browse([typelist:Array]) : Boolean
Player version: | Flash Player 8 |
FileReference.browse()
is called, the FileReference object's properties are reset to the file selected by the user in the dialog box. Only one browse()
or download()
session can be performed at a time (because only one dialog box can be displayed at a time).
You can pass an array of file types to determine which files the dialog box displays.
Parameterstypelist:Array [optional] — An array of file types used to filter the files displayed in the dialog box. If you omit this parameter, all files are displayed. If you include this parameter, the array must contain one or more elements enclosed in curly braces { }. You can use one of two formats for the array:
The two formats are not interchangeable in a single The list of extensions is used to filter the files in Windows, depending on the file selected by the user. It is not actually displayed in the dialog box. To display the file types for users, you must list the file types in the description string as well as in the extension list. The description string is displayed in the dialog box in Windows. (It is not used on the Macintosh.) On the Macintosh, if you supply a list of Macintosh file types, that list is used to filter the files. If you don't supply a list of Macintosh file types, the list of Windows extensions is used. |
Boolean —
Returns true if the parameters are valid and the file-browsing dialog box is displayed. Returns false if the dialog box is not displayed, if another browse session is already in progress, or if you use the typelist parameter but fail to provide a description or extension string in any element in the array.
|
import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("Opened " + file.name); } listener.onCancel = function(file:FileReference):Void { trace("User cancelled"); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse();
FileReferenceList.onSelect, FileReference.onCancel, FileReference.download(), FileReferenceList.browse() |
public cancel() : Void
Player version: | Flash Player 8 |
import flash.net.FileReference; var listener:Object = new Object(); listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); if(bytesLoaded >= (bytesTotal / 2)) { file.cancel(); } } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf");
public download(url:String, [defaultFileName:String]) : Boolean
Player version: | Flash Player 8 |
This method first opens an operating-system dialog box that asks the user to enter a filename and select a location on the local computer to save the file. When the user selects a location and confirms the download operation (for example, by clicking Save), the download from the remote server begins. Listeners receive events to indicate the progress, success, or failure of the download. To ascertain the status of the dialog box and the download operation after calling download()
, your ActionScript code must listen for events by using event listeners such as onCancel
, onOpen
, onProgress
, and onComplete
.
When the file has successfully downloaded, the properties of the FileReference object are populated with the properties of the local file and the onComplete
listener is invoked.
Only one browse()
or download()
session can be performed at a time (because only one dialog box can be displayed at a time).
This method supports downloading of any file type, with either HTTP or HTTPS. You can also send data to the server with the download()
call by appending parameters to the URL, for the server script to parse.
When using this method, consider the Flash Player security model:
For more information, see the following:
url:String — The URL of the file to download to the local computer. You can send data to the server with the download() call by appending parameters to the URL, for the server script to parse. For example:http://www.myserver.com/picture.jpg?userID=jdoe On some browsers, URL strings are limited in length. Lengths greater than 256 characters may fail on some browsers or servers. |
|
defaultFileName:String [optional] — The default filename displayed in the dialog box, for the file to be downloaded. This string cannot contain the following characters: / \ : * ? " < > | % If you omit this parameter, the filename of the remote URL is parsed out and used as the default. |
Boolean —
A value of true if the dialog box in which a user can select a file is displayed. If the dialog box is not displayed, the method returns false . The dialog box could fail to be displayed for any of the following reasons:
|
download
method. Notice that there are listeners for all of the events. import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("onSelect: " + file.name); } listener.onCancel = function(file:FileReference):Void { trace("onCancel"); } listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); } listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); } listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } listener.onIOError = function(file:FileReference):Void { trace("onIOError: " + file.name); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; if(!fileRef.download(url, "FlashPlatform.pdf")) { trace("dialog box failed to open."); }
FileReference.browse(), FileReferenceList.browse(), FileReference.upload() |
public removeListener(listener:Object) : Boolean
Player version: | Flash Player 8 |
listener:Object — An object that listens for a callback notification from the FileReference event listeners. |
Boolean —
Returns true if the object specified in the listener parameter was successfully removed. Otherwise, this method returns false .
|
removeListener
method. If a user cancels the download, the listener is removed so that it no longer receives events from that FileReference object. import flash.net.FileReference; var listener:Object = new Object(); listener.onCancel = function(file:FileReference):Void { trace(file.removeListener(this)); // true } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf");
public upload(url:String) : Boolean
Player version: | Flash Player 8 |
FileReference.browse()
or FileReferenceList.browse()
before calling this method. Listeners receive events to indicate the progress, success, or failure of the upload. Although you can use the FileReferenceList object to let users select multiple files to upload, you must upload the files one by one. To do so, iterate through the FileReferenceList.fileList
array of FileReference objects.
The file is uploaded to the URL passed in the url
parameter. The URL must be a server script configured to accept uploads. Flash Player uploads files using the HTTP POST
method. The server script that handles the upload should expect a POST
request with the following elements:
Content-Type
element of multipart/form-data
Content-Disposition
element with a name
attribute set to "Filedata"
and a filename
attribute set to the name of the original fileHere is a sample POST
request:
Content-Type: multipart/form-data; boundary=AaB03x --AaB03x Content-Disposition: form-data; name="Filedata"; filename="example.jpg" Content-Type: application/octet-stream ... contents of example.jpg ... --AaB03x--
You can send data to the server with the upload()
call by appending parameters to the URL.
Note: If your server requires user authentication, only SWF files running in a browser—that is, using the browser plug-in or ActiveX control—can provide a dialog box to prompt the user for a user name and password for authentication, and only for downloads. For uploads that use the plug-in or ActiveX control, and for uploads and downloads that use the stand-alone or external player, the file transfer fails.
When using this method, consider the Flash Player security model:
For more information, see the following:
url:String — The URL of the server script configured to handle upload through HTTP POST calls. The URL can be HTTP or, for secure uploads, HTTPS. You can send data to the server with the On some browsers, URL strings are limited in length. Lengths greater than 256 characters may fail on some browsers or servers. |
Boolean —
A value of false in any of the following situations:
|
upload()
method by first prompting the user to select a file to upload, then handling the onSelect
and onCancel
listeners, and finally handling the results of the actual file upload. import flash.net.FileReference; var allTypes:Array = new Array(); var imageTypes:Object = new Object(); imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)"; imageTypes.extension = "*.jpg; *.jpeg; *.gif; *.png"; allTypes.push(imageTypes); var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("onSelect: " + file.name); if(!file.upload("http://www.yourdomain.com/yourUploadHandlerScript.cfm")) { trace("Upload dialog failed to open."); } } listener.onCancel = function(file:FileReference):Void { trace("onCancel"); } listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); } listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); } listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } listener.onHTTPError = function(file:FileReference):Void { trace("onHTTPError: " + file.name); } listener.onIOError = function(file:FileReference):Void { trace("onIOError: " + file.name); } listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); } var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse(allTypes);
FileReference.browse(), FileReferenceList.browse(), FileReference.download(), FileReferenceList.fileList |
Properties | Events | Methods |