View comments | RSS feed

FileReferenceList (flash.net.FileReferenceList)


Object
    |
    +-flash.net.FileReferenceList

public class FileReferenceList
extends Object

The FileReferenceList class provides a means to let users select one or more files for uploading. A FileReferenceList object represents a group of one or more local files on the user's disk as an array of FileReference objects. For detailed information and important considerations about FileReference objects and the FileReference class, which you use with FileReferenceList, see the FileReference class.

To work with the FileReferenceList class:

The FileReferenceList class includes a browse() method and a fileList property for working with multiple files.

Availability: ActionScript 1.0; Flash Player 8

Example

The following example allows a user to select multiple files and then uploads each of them to a server.

import flash.net.FileReferenceList;
import flash.net.FileReference;

var listener:Object = new Object();

listener.onSelect = function(fileRefList:FileReferenceList) {
    trace("onSelect");
    var list:Array = fileRefList.fileList;
    var item:FileReference;
    for(var i:Number = 0; i < list.length; i++) {
        item = list[i];
        trace("name: " + item.name);
        trace(item.addListener(this));
        item.upload("http://www.yourdomain.com/");
    }
}

listener.onCancel = function():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, httpError:Number):Void {
    trace("onHTTPError: " + file.name + " httpError: " + httpError);
}

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:FileReferenceList = new FileReferenceList();
fileRef.addListener(listener);
fileRef.browse();

See also

FileReference (flash.net.FileReference)

Property summary

Modifiers

Property

Description

 

fileList:Array

An array of FileReference objects.

Properties inherited from class Object

constructor, __proto__, prototype, __resolve


Event summary

Event

Description

onCancel = function(fileRefList:FileReferenceList) {}

Invoked when the user dismisses the file-browsing dialog box.

onSelect = function(fileRefList:FileReferenceList) {}

Invoked when the user selects one or more files to upload from the file-browsing dialog box.

Constructor summary

Signature

Description

FileReferenceList()

Creates a new FileReferenceList object.

Method summary

Modifiers

Signature

Description

 

addListener(listener:Object) : Void

Registers an object to receive notification when a FileReferenceList event listener is invoked.

 

browse([typelist:Array]) : Boolean

Displays a file-browsing dialog box in which the user can select one or more local files to upload.

 

removeListener(listener:Object) : Boolean

Removes an object from the list of objects that receive event notification messages.

Methods inherited from class Object

addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch



Version 8

Comments


No screen name said on Nov 10, 2005 at 1:40 AM :
Hi, i tried to use this example and uploaded it to my domain.
when i upload the file, it shows the bytes progress but eventualy gives me an HTTP error num 405.
have i misssed something?
Tamir
spor1 said on Nov 10, 2006 at 3:58 PM :
Greetings.. noticed your issue.. error 405 is a "method not allowed" error.. Technically, if you are uploading something to your server, you need a backend script to authorize and handle the transaction between your flash file and the actual server. I believe this may only be for swf's that are local. Not sure if this is totally necessary when the file is on server.

Im using a file upload for my current site that lets users upload their music to selected folders on my server. I have a php script that handles the file after it leaves the flash environment. you can try it out at www.hypetunes.com Check in any of the radio areas.

-Spor1
www.spor1.com

 

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/00002226.html