/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//CODE import com.adobe.images.JPGEncoder; import flash.display.BitmapData; import flash.net.URLRequest; import flash.net.URLRequestHeader; import flash.net.URLRequestMethod; import flash.net.navigateToURL; var myBitmapData:BitmapData = new BitmapData(100, 100, false, 0xFFFFFF); var jpgEncoder:JPGEncoder = new JPGEncoder(85); var jpgStream:ByteArray = jpgEncoder.encode(myBitmapData); var fileName:String='Name'; jpgStream.writeMultiByte("_s_"+fileName,"us-ascii"); var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream"); var request:URLRequest = new URLRequest("myJpgSaver.php"); request.requestHeaders.push(header); request.method = URLRequestMethod.POST; request.data = jpgStream; navigateToURL(request, "_blank"); myBitmapData.dispose(); //myJpgSaver.php <?PHP if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) { $parts=explode("_s_", $GLOBALS["HTTP_RAW_POST_DATA"]); $name=$parts[1]; $fp = fopen( $name.".jpg", 'wb' ); fwrite( $fp, $parts[0] ); fclose( $fp ); } ?>