Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

FileReference

New Here ,
Sep 27, 2009 Sep 27, 2009

Hey, i'm trying to create a multiple file uploader using FileReference. The user should be able to select more than one file but i don't want to use FileReferenceList for this. So instead the user opens the Browse dialog, picks a file then opens up the Browse dialog again, picks another file etc.

To make this work i'm trying to copy the FileReference object into an array, but this isn't really working. Here's how i do it:

fileref.as

import flash.net.FileReference;

class fileref {
public var fileRef:FileReference;// = new FileReference();
}

main project (which omports the fileref.as)

var listener:Object = new Object();
listener.onSelect = function(file:FileReference) {
var tC:fileref = new fileref();
tC.fileRef = file;
arrRef.push( tC );

    for(var i:Number = 0; i < arrRef.length; i++) {

        trace("name: " + arrRef.fileRef.name);
    }

}

As you can see i'm trying to store the parameter 'file'  into an instance of the class 'fileref', this works the first time cause then i get this output:

name: image1.jpg

After i open the Browse dialog again and select a file i should get this as outpupt:

name: image1.jpg

name: image2.jpg

But instead i get:

name: image2

name: image2

Why is this happening?? And how can i make it so, that i can add multiple files..??

TOPICS
ActionScript
567
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2009 Sep 27, 2009

you should be pushing file into your array and checking the array element's name:


var listener:Object = new Object();
listener.onSelect = function(file:FileReference) {

arrRef.push( file );

    for(var i:Number = 0; i < arrRef.length; i++) {

        trace("name: " + arrRef.name);
    }

}


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 27, 2009 Sep 27, 2009

This gives me the exact same result as before...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2009 Sep 28, 2009
LATEST

no it won't.  unless you're making some additional error(s).

show your corrected code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines