4 Replies Latest reply on Apr 12, 2010 12:39 AM by David_F57

    How to put a image url to a text field in flex

    pogla129 Level 1

      I am facing problem when getting

      a image  url  with the help

      of    FileReference ..  Actuallly  i want to display the  image url to a text field after browsing the image location when I press

      a button............. my code is given below

       

      private function getImageUrl():void {
                     private var fileRef:FileReference = new FileReference();
                     fileRef.browse();
              

       

                  }

      Any one can help me to solve the problem

        • 1. Re: How to put a image url to a text field in flex
          David_F57 Level 5

          Hi,

           

          If you use file reference with an AIR app you have access to the file path, with a browser based app security prevents you from having access to the file path you can access the name of the file only.

           

          this is an example of grab a list of files(images) using filereferencelist and filereference and displaying the image in a list, its a similar process for just getting a list of file names

           

          http://gumbo.flashhub.net/pagedrop/  sourcecode enabled (right click in the browser and select view source)

           

           

          for filereference  the name property will return the file name only not the path

           

          for filereferencelist you have the .filelist[X].name to get the file name.

           

          hope this helps

           

          David

           

           

          • 2. Re: How to put a image url to a text field in flex
            David_F57 Level 5

            Just one last thing for your code

             

            private var fileRef:FileReference = new FileReference();  <--- declare the filerefence so that it is available for all your functions

             

            private function getImageUrl():void

            {

                           fileref.addEventListener(Event.SELECT, myselectedfile);

                           fileRef.browse();

             

             

             

              }


             

             

            private function myselectedfile(e:Event): void

            {

                 mytextfield.text = fileref.name;

            }

             

             

             

            David

            • 3. Re: How to put a image url to a text field in flex
              Rajib123

              Thanx  for help...........I am now  getting the image name properly  but would you please   tell me about how to get the proper location of the image

              and put the location url in the text field..............

              • 4. Re: How to put a image url to a text field in flex
                David_F57 Level 5

                Hi,

                 

                As I explained due to security of the flashplayer you can not get the full path of a local file, If you create an AIR application it runs 'natively' so you can get the full path of a local file.

                 

                 

                David.