6 Replies Latest reply on May 12, 2006 10:47 AM by Joekin

    How can i Upload Files from my Flex 2.0 Application?

    tantalo
      How can i do a Upload File funtionality with Flex 2.0? Do i have to make the component? How is the code in Flex/ Action Script to make this possible?. I'm new in this Flex world and it seems to me very interesting to make RIA's Applications; in fact i'm making a little Employees Application for my company and i'm trying this technology and of course i need the functionality that i asking for.

      Regards.

      Andres.
        • 1. Re: How can i Upload Files from my Flex 2.0 Application?
          Level 7
          There's an example here:
          http://labs.adobe.com/svn/flashplatform/?/projects/actionscriptsamples/tags/0_1_0/src/acti onscript3/fileupload/FileUpload/

          There may be some slight changes you need to make to the code since we've
          been updating the APIs, but the basic structure hasn't changed.

          Phil Costa
          Group Product Manager, Flex

          "tantalo" <webforumsuser@macromedia.com> wrote in message
          news:e3fq06$ncv$1@forums.macromedia.com...
          > How can i do a Upload File funtionality with Flex 2.0? Do i have to make
          > the
          > component? How is the code in Flex/ Action Script to make this possible?.
          > I'm
          > new in this Flex world and it seems to me very interesting to make RIA's
          > Applications; in fact i'm making a little Employees Application for my
          > company
          > and i'm trying this technology and of course i need the functionality that
          > i
          > asking for.
          >
          > Regards.
          >
          > Andres.
          >


          • 2. Re: How can i Upload Files from my Flex 2.0 Application?
            tantalo Level 1
            Thanks Phil. The example works!. There are only two changes to make to the original code:

            1. The xml namespaces to Adobe.
            2. The class AlertClickEvent, needs to be replace for the CloseEvent Class.

            Regards.

            Andres.
            • 3. Re: How can i Upload Files from my Flex 2.0 Application?
              tantalo Level 1
              Hi. Phil, how i commented in the forum the examples works ok, with a little changes to make a file Upload. Now i have another doubt, i need to make a submit of a form with another fields and the file selected.

              I made a HHTP Service for that purpose with the tags Requests like:

              <mx:HTTPService id="empleadoRequest" url=" http://andresbarrios:8080/directorio/empleados/insertarEmpleado.jsp"
              useProxy="false" method="POST">
              <mx:request xmlns="">
              <empresa>{empresa.selectedItem.data}</empresa>
              <ubicacion>{ubicacion.selectedItem.data}</ubicacion>
              <departamento>{departamento.selectedItem.data}</departamento>
              <cedula>{cedula.text}</cedula>
              <nombre>{nombre.text}</nombre>
              <apellido>{apellido.text}</apellido>
              <!--Falta Fecha de Nacimiento -->
              <sexo>{sexo.selectedItem.data}</sexo>
              <estado_civil>{estado_civil.selectedItem.data}</estado_civil>
              <telefono_celular>{telefono_celular.text}</telefono_celular>
              <extension>{extension.text}</extension>
              <correo_electronico>{correo_electronico.text}</correo_electronico>
              </mx:request>
              </mx:HTTPService>
              I have the global variable called "file" that contains the file selected. I want to send this file variable in the HHTPservice call EmpleadoRequest, can i do that with a Request tag like another field? or the only way is trougth: file.upload(upload.cfm) ?;

              I want only make a one call to the server to submit the fields of the form and to upload the file at th e same time can you help me How can i do that?

              Thanks.

              Regards.

              Andres.

              • 4. Re: How can i Upload Files from my Flex 2.0 Application?
                Level 7
                I haven't tried this, but I believe what you could do is append
                requestHeaders to the urlrequest object that you pass into the file.upload()
                method. The requestHeaders is an array of name/value pairs that would be
                included with your post. At least in theory, I believe that shoudl work.

                Good luck.

                Phil


                "tantalo" <webforumsuser@macromedia.com> wrote in message
                news:e3q3mt$138$1@forums.macromedia.com...
                > Hi. Phil, how i commented in the forum the examples works ok, with a
                > little
                > changes to make a file Upload. Now i have another doubt, i need to make a
                > submit of a form with another fields and the file selected.
                >
                > I made a HHTP Service for that purpose with the tags Requests like:
                >
                > <mx:HTTPService id="empleadoRequest"
                > url=" http://andresbarrios:8080/directorio/empleados/insertarEmpleado.jsp"
                > useProxy="false" method="POST">
                > <mx:request xmlns="">
                > <empresa>{empresa.selectedItem.data}</empresa>
                > <ubicacion>{ubicacion.selectedItem.data}</ubicacion>
                > <departamento>{departamento.selectedItem.data}</departamento>
                > <cedula>{cedula.text}</cedula>
                > <nombre>{nombre.text}</nombre>
                > <apellido>{apellido.text}</apellido>
                > <!--Falta Fecha de Nacimiento -->
                > <sexo>{sexo.selectedItem.data}</sexo>
                > <estado_civil>{estado_civil.selectedItem.data}</estado_civil>
                > <telefono_celular>{telefono_celular.text}</telefono_celular>
                > <extension>{extension.text}</extension>
                > <correo_electronico>{correo_electronico.text}</correo_electronico>
                > </mx:request>
                > </mx:HTTPService>
                > I have the global variable called "file" that contains the file selected.
                > I
                > want to send this file variable in the HHTPservice call EmpleadoRequest,
                > can i
                > do that with a Request tag like another field? or the only way is trougth:
                > file.upload(upload.cfm) ?;
                >
                > I want only make a one call to the server to submit the fields of the form
                > and
                > to upload the file at th e same time can you help me How can i do that?
                >
                > Thanks.
                >
                > Regards.
                >
                > Andres.
                >
                >
                >


                • 5. Re: How can i Upload Files from my Flex 2.0 Application?
                  tantalo Level 1
                  Thanks for tour Reply Phil, i will try this, in theory it would work.

                  Andres.
                  • 6. Re: How can i Upload Files from my Flex 2.0 Application?
                    Joekin Level 1
                    Hi Andres,

                    I was curious about the upload feature and trying to test it on my machine but I could not make the upload example work. Everything is fine except when I click Yes from upload confirmtion nothing happens. The file is not loaded at all, however, no error message is given anywhere.

                    In my test, everything is local, I set upload url to be " http://127.0.0.1:8080/UploadApp/upload.cfm", hosted under Tomcat server in XP; and I access the upload flex2 app via url like " http://127.0.0.1:8080/UploadApp/FileUploadExample.html". The html is just a simple wrapper of the SWF. The upload.cfm is placed under " http://127.0.0.1:8080/UploadApp", and inside upload.cfm the destination is a valid local path. Do I need to do any security settings first? Since you have made it work, I wondered if you have any suggestions.

                    Thanks,
                    Joe