title: Save image from Flash, send it to PHP and return a URL string to Flash
body: <p>I use this code to convert an image to a BitmapData and store a JPG in a ByteArray.</p>
  
  <pre><code>import com.adobe.images.JPGEncoder;
  
  var jpgSource:BitmapData = new BitmapData (img_mc.width, img_mc.height);
  jpgSource.draw(img_mc);
  
  var jpgEncoder:JPGEncoder = new JPGEncoder(85);
  var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
  
  // here we need some code to send the bytearray but I lack enough knowledge to do it by myself
  </code></pre>
  
  <p>Now, I want to do the following:
  1. send the ByteArray to PHP;
  2. PHP must store a physical image_id.jpg on server;
  3. then PHP must return the URL of the image to Flash;</p>
  
  <p>Is this possible? How?</p>
  
  <p>The first lines of PHP could be:</p>
  
  <pre><code>if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
  {
      // get bytearray
      $jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
  
      // but I don't know how to save the image on disk and how to return the URL of the //image
  }
  </code></pre>
  
  <p>Thanks!</p>