FileReference
Copy link to clipboard
Copied
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..??
Copy link to clipboard
Copied
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);
}}
Copy link to clipboard
Copied
This gives me the exact same result as before...
Copy link to clipboard
Copied
no it won't. unless you're making some additional error(s).
show your corrected code.

