A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: PNGEncoder with PHP

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    1

    PNGEncoder with PHP

    I am trying to utilize the PNGEncoder with the dynamicfash Base64 to send a Base64 String to PHP and save the PNG File but for some reason that i cannot figure out, the PNG file is never readable. It is there and has a size (contains data) but cannot be opened by anything so is not a valid png file. Here is my code...

    Code:
    	var target:MovieClip = new MovieClip();
    	target.graphics.beginFill(0xff0000,5.0);
    	target.graphics.drawRect(0,0,100,100);
    	target.graphics.endFill();
    	
    	var bdata:BitmapData = new BitmapData(100, 100);            
    	bdata.draw(target);  
    	var stream:ByteArray = PNGEncoder.encode(bdata);             
    	var byteArrayAsString:String = Base64.encodeByteArray(stream);
    
    	var request:URLRequest = new URLRequest("pngsave.php");
    	request.method = URLRequestMethod.POST;
    	var variables:URLVariables = new URLVariables();
       	variables.fileName = "testing.png";
       	variables.image = byteArrayAsString;
       	request.data = variables;
    	navigateToURL(request, "_blank");
    and the Php...

    Code:
    <?php
    
    header('Content-Type: image/png');
    header("Content-Disposition: attachment; filename=".$_POST['fileName']);
       
    echo base64_decode($_POST["image"]);
    ?>
    Any ideas on what I am doing wrong here?

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I am not sure what exactly is wrong, however here is a class, SaveByteArray, and an example, with which you can save an image on the server.

    http://flashscript.biz/flashas3/biz/index.html
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center