As3+pngencoder PHP Upload Image
November 01, 2010
Import Com.adobe.images.JPGEncoder;
Import Flash.display.BitmapData;
Import Flash.display.Sprite;
Import Flash.net.URLLoader;
Import Flash.net.URLRequest;
Import Flash.net.URLRequestHeader;
Import Flash.net.navigateToURL;
Import Flash.utils.ByteArray;
Draw Bitmap Data
var jpgsource:bitmapdata = new BitmapData (picture.width, picture.height);
Jpgsource.draw (picture);
Generating an encoding container
var jpgencoder:jpgencoder = new Jpgencoder (95);
Encode the bitmap data into a container to become a bytearray stream
var Jpgstream:bytearray = Jpgencoder.encode (Jpgsource);
Compress ByteArray Stream This step test if you get rid of the image cannot be generated
Jpgstream.compress ();
Add header request for stream
var header:urlrequestheader = new Urlrequestheader ("Content-type", "Application/octet-stream");
var jpgurlrequest:urlrequest = new URLRequest ("save.php");
JpgURLRequest.requestHeaders.push (header);
Jpgurlrequest.method = "POST";
Jpgurlrequest.data = Jpgstream;
Push picture data to server side
Navigatetourl (jpgurlrequest, "_blank");
In the case of urlloader, it is necessary to indicate that the data is a ByteArray object containing the raw binary data
Loader.dataformat = urlloaderdataformat.binary;
Server-side:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.