Uploading multiple images/data to server!


Oh man what a life saver this was! Super easy to implement and works awesomely so far!

Multipart form data in as3 [Class version 1.2]

Implementing is as easy as this:

jpgEncoder = new JPGEncoder( 100 )			
			
var photo:ByteArray = jpgEncoder.encode( this.getBitmapData( photoBitmap) );
var thumbnail:ByteArray = jpgEncoder.encode( this.getBitmapData(thumbnailBitmap) );
			
var ml:MultipartURLLoader = new MultipartURLLoader();
ml.dataFormat = URLLoaderDataFormat.TEXT; // or whatever works for the response you receive back
			
ml.addEventListener(Event.COMPLETE, onSaveSucces);
ml.addVariable('someText', 'blah blah');
ml.addFile(photo, 'photo.jpg', 'photo');
ml.addFile(thumbnail, 'thumbnail.jpg', 'thumbnail');
ml.load('my/server/path/postImage.php');

For more info on how to set up the php just go to the link!

,

Leave a Reply