1 Reply Latest reply on Jan 4, 2009 12:24 AM by vscmaster

    Upload files to server

    vscmaster Level 1
      Hello!
      Me need load images to folder on the server, I using TomCat and front-end Spring.

      Can I have upload files(to context root) without any URLRequest ???

      Or how I can make correct example below?

      My example:

      var uploder:FileReference = new FileReference();
      uploder.addEventListener(Event.SELECT, selectHandler);
      uploder.addEventListener(Event.COMPLETE, completeHandler);
      var arr:Array = [];
      arr.push(new FileFilter("Images", "*.gif;*.jpeg;*.jpg;*.png"));
      //uploder.browse(arr);
      try
      {
      var success:Boolean = uploder.browse(arr);
      }
      catch (error:Error)
      {
      trace("Unable to browse for files.");
      Alert.show("Unable to browse for files.");
      }

      function selectHandler(event:Event):void
      {
      //Alert.show("upload file.");
      var request:URLRequest = new URLRequest(" http://localhost:8080/simpleflex/terr.gif")
      try
      {
      uploder.upload(request);
      }
      catch (error:Error)
      {
      Alert.show("Unable to upload file.");
      trace("Unable to upload file.");

      }
      }

      function completeHandler(event:Event):void
      {
      trace("uploaded");
      Alert.show(ObjectUtil.toString(uploder));
      }