2 Replies Latest reply on Jun 3, 2009 7:44 AM by Andre Brito

    Adding images to ArrayCollection using FileReference.

    Andre Brito

      Hi guys. Can someone tell me, please, how can I add images to an arraycollection? I'm using filereference, and it's something like adding it to a list, and then upload them in one click. I have a button ("Choose image") that will call fileReference.browse(). But I can't get the images (the hole path of the images). How can I do that?

        • 1. Re: Adding images to ArrayCollection using FileReference.
          *Prashant Shelke* Level 4


          You can achieve this by storing var fileRef:FileReference instances in one arrayCollection, while uploading upload one-by one files.

          see following code:

                                              var fileRef:FileReference  = new FileReference();
                                              var xlsTypes:FileFilter = new FileFilter("All Excel Files","*.xls;");
                                              var allTypes:Array = new Array(xlsTypes);
                                                  var success:Boolean = fileRef.browse();
                                              catch (error:Error)
                                                  mx.controls.Alert.show("error is "+ error);
                                              fileRef.addEventListener(Event.SELECT, selectEvent);


          in the selectEvent function you can add this reference to an arrayCollection().


          http://whatilearned2day.wordpress.com/2008/01/31/extracting-full-path-while-uploading-a-fi le-to-server-in-flex/

          http://blog.flexexamples.com/2007/09/21/uploading-files-in-flex-using-the-filereference-cl ass/

          Hope this will help you.


          1 person found this helpful
          • 2. Re: Adding images to ArrayCollection using FileReference.
            Andre Brito Level 1

            Hi Prashant. Your answer was very helpful.


            I'm using Flex in a web application. So I can't get the hole path without uploading the file into the server, right? I mean... I can't test that withou creating a .extensionOfTheBackEndProgrammingLanguageThatIllUse that store that image, can I?