3 Replies Latest reply on Sep 19, 2008 2:20 AM by laster11

    How to save Image in RIA?

    laster11
      How can I save an Image or BitmapData object as a png file in server in RIA?
        • 1. Re: How to save Image in RIA?
          michel_v Level 1
          I do the following:
          - encode the image with png or jpeg encoder class
          - convert it to b64 to send it
          - send it to a tiny php script that store it as a file on the server

          if goes like this:
          private function SaveBitmap():void {
          // save and encode bitmap
          var bmp:BitmapData = new BitmapData(this.width, this.height);
          bmp.draw(this);
          var png:PNGEncoder = new PNGEncoder();
          var data:ByteArray = png.encode(bmp);
          var b64:Base64Encoder = new Base64Encoder();
          b64.encodeBytes(data);
          var str:String = b64.drain();
          // send to server
          var variables:Object = new Object();
          variables.BitMap = str;
          var http:HTTPService = new HTTPService();
          http.method = "POST";
          http.addEventListener(ResultEvent.RESULT, SaveBitmapOK);
          http.addEventListener(FaultEvent.FAULT, SaveBitmapError);
          http.request = variables;
          http.url = "/xxxxx/SaveImage.php;
          http.send();
          }
          • 2. Re: How to save Image in RIA?
            laster11 Level 1
            Excuse me.Pls tell me how to write the PHP?Thank you!
            • 3. Re: How to save Image in RIA?
              laster11 Level 1
              quote:

              Originally posted by: michel_v
              I do the following:
              - encode the image with png or jpeg encoder class
              - convert it to b64 to send it
              - send it to a tiny php script that store it as a file on the server

              if goes like this:
              private function SaveBitmap():void {
              // save and encode bitmap
              var bmp:BitmapData = new BitmapData(this.width, this.height);
              bmp.draw(this);
              var png:PNGEncoder = new PNGEncoder();
              var data:ByteArray = png.encode(bmp);
              var b64:Base64Encoder = new Base64Encoder();
              b64.encodeBytes(data);
              var str:String = b64.drain();
              // send to server
              var variables:Object = new Object();
              variables.BitMap = str;
              var http:HTTPService = new HTTPService();
              http.method = "POST";
              http.addEventListener(ResultEvent.RESULT, SaveBitmapOK);
              http.addEventListener(FaultEvent.FAULT, SaveBitmapError);
              http.request = variables;
              http.url = "/xxxxx/SaveImage.php;
              http.send();
              }



              please tell me how to write the SaveImage.php??Thank you very much!