0 Replies Latest reply on Jun 8, 2010 1:58 PM by jimmyoneshot

    Problems With jpeg Upload From Flex App

    jimmyoneshot Level 1

      I want to allow users of my app to take a snapshot of a component 'linkViewer' and then make this jpeg a snapshot so it can be uploaded to my server space via my predefined upload.php script 'imageUploadUrlRequest'. However the only way I can do this is if I set it up to save the images created in a desktop directory so that there is actually something to upload. Is there any way I can edit the following code so that the jpeg simply gets uploaded straight away rather than being saved, then uploaded? :-


      var bigbmd:BitmapData = ImageSnapshot.captureBitmapData(linkViewer);            
      var scale:Number = 0.50; 
      var matrix:Matrix = new Matrix(); 
      matrix.scale(scale, scale);
      var smallbmd:BitmapData = new BitmapData(bigbmd.width * scale, bigbmd.height * scale, true, 0x000000);
      smallbmd.draw(bigbmd, matrix, null, null, null, true);               
      var jpgEncoder:JPEGEncoder = new JPEGEncoder( 100 );
      var ba:ByteArray = jpgEncoder.encode(smallbmd);
      var file:File = File.desktopDirectory.resolvePath(('createdimages/')+enteredimagename+('.jpg'));
      var wr:File = new File(file.nativePath);
      var stream:FileStream = new FileStream();
      stream.open( wr, FileMode.WRITE);
      stream.writeBytes ( ba, 0, ba.length );


      'enteredimagename' is simply the value of a text input that the user uses to name these images in the app.


      Any help would be greatly appreciated.