View comments | RSS feed

browse (FileReference.browse method)

public browse([typelist:Array]) : Boolean

Displays a file-browsing dialog box in which the user can select a local file to upload. The dialog box is native to the user's operating system. When you call this method and the user successfully selects a file, the properties of this FileReference object are populated with the properties of that file. Each subsequent time that 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.

Availability: ActionScript 1.0; Flash Player 8

Parameters

typelist: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 browse() call. You must use one or the other.

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.

Returns

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.

Example

The following example displays a dialog box in which the user can select an image file to be uploaded.

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(); 

See also

onSelect (FileReferenceList.onSelect event listener), onCancel (FileReference.onCancel event listener), download (FileReference.download method), browse (FileReferenceList.browse method)


Version 8

Comments


newyorkr said on Jan 3, 2006 at 6:16 AM :
Is there any way to show 'resize handle' in the file browse dialogue box? I saw the resize handle in file browse box in the Global Security Settings flash movie. (http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html) There must be a way to do that. I'm also wondering if it's possible to change the title of the dialogue box.
danpamfil said on Apr 13, 2006 at 6:13 AM :
can i see target of file?
r_noise said on Jun 23, 2006 at 8:33 AM :
Beware that if the typelist array is invalid or undefined the browse method will fail silently.
webweber said on Oct 19, 2006 at 10:52 PM :
> The following example displays a dialog box in which the user can select an image file to be uploaded.

... or any other type of file.

Shoudn't it be:
var fileTypes = [{description: "Image files", extension: "*.jpg;*.gif;*.png", macType: "JPEG;jp2_;GIFF"}]
fileRef.browse(fileTypes);
webweber said on Oct 30, 2006 at 12:03 AM :
These hints regarding issues with Mac types is essential information which should be part of this documentation:
http://www.joshbuhler.com/2006/05/30/mac-file-types-one-more-thing/
No screen name said on Dec 18, 2006 at 1:50 PM :
Per 'resize handle' for the file browse dialogue box, it seems like adobe flash team has fixed it in the latest version of flash player (9.0.28.0). I can see resize handle now. Thanks Adobe Flash team.
victor.lopez said on Jun 6, 2007 at 12:53 PM :
hey I've a little problem in here. I'm making an uploader
which browse method only searches for video files.

reference.browse([{description:"Video Files", extension:"*.mpg;*;mpeg;*.mp4;*.avi;*.mov;*.wmv;*.flv"}]);

But when I upload it on the internet, and then I click the browse button I can access to the files I describe.

Someone who knows a possible solution??

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00002206.html