2 Replies Latest reply on Apr 18, 2011 9:49 AM by Anakin1989

    Begginer question



      I will start by saying that i'm a begginer with Flex.

      What i need to do is save a file locally (it's a school project so i don't use a server). The user will choose a picture file (i use FileReference) and, because i understand that for security reasons i can't get it's absolute path, i want to save it locally, to a known folder. I use this code, but it doesn't work:




      protected function button1_clickHandler(event:MouseEvent):void


      fileRef =


      new FileReference();

      fileRef.addEventListener(Event.SELECT, selectHandler);




      protected function selectHandler(event:Event):void







      But it doesn't create any file, i also tried using a simple string instead of fileRef.data and still it doesn't create the file. Please tell me how to save a file chose by the user to another file (copy and paste, in other words).

      Thank you very much.



        • 1. Re: Begginer question
          oldMster Level 3

          For the same security reasons, you can't programatically save a file anywhere on the client's file system (if you are running the flex application in a browser, the rules are different if you are creating an AIR application).  Just like in any browser application, you have to have the user select the save location with a dialog box.  I don't recall the details, since I don't do this often, but if you look at the filereference documentation, I think it will lead you in the right direction.



          • 2. Re: Begginer question
            Anakin1989 Level 1

            Thank you for your answer, in the meanwhile i changed my program to run in adobe air because, like you said, the rules are different with it, so the application works fine now using file instead of filereference.