title: Saving images from flash to server using PHP
body: <p>I am trying to save some images from Flash to Php by sending a jpgstream, capturing it in php and pushing it to a file. Not sure what I am doing wrong here.</p>
  
  <p>I am putting all the images I need into an array like so: (history is just where I am keeping all the image data)</p>
  
  <pre><code>for each($value in history)
              {
  
                  var jpgSource:BitmapData = new BitmapData ($value.sourceImg.width, $value.sourceImg.height);
                  jpgSource.draw($value.sourceImg);
                  var encoder:JPEGEncoder = new JPEGEncoder(100);
                  var jpgStream:ByteArray =  encoder.encode(jpgSource);
                  var imgDetailArr:Array = new Array(jpgStream, $value.name);
                  imgArr.push(imgDetailArr);
  
  
  
              }
  </code></pre>
  
  <p>And then i send that to PHP using a remote object and amfphp:</p>
  
  <pre><code>rmObj.saveUserImages( imgArr);
  </code></pre>
  
  <p>On the php side I am doing this:</p>
  
  <pre><code>function saveUserImages( $imgArr)
      {
          foreach($imgArr as $value)
          {
  
  
              ob_start();
              /* output image as JPEG */
              $image = imagecreatefromjpeg($value[0]);     
              header('Content-type: image/jpeg');
              imagejpeg( $image );
              /* save output as file */
              ob_flush();
              file_put_contents( "images", ob_get_contents() );
  
  
          }
      }
  </code></pre>
  
  <p>But this doesn't seem to do the trick. I have been going through a bunch of different tutes and code snippets, so maybe I just ogt something confused along the way.  I have done this before though and don't remember it being this difficult. </p>