<?PHP
//print_r($_FILES);
$target_path = $_REQUEST[ ‘path’ ];
$target_path = $target_path . basename( $_FILES[ ‘Filedata’ ][ ‘name’ ] );

if ( move_uploaded_file( $_FILES[ ‘Filedata’ ][ ‘tmp_name’ ], $target_path ) )
{
echo “The file ” . basename( $_FILES[ ‘Filedata’ ][ ‘name’ ] ) . ” has been uploaded;”;

$_SESSION[‘card_image’]    =    basename( $_FILES[ ‘Filedata’ ][ ‘name’ ] );
chmod(‘/images/designcards/’.basename( $_FILES[ ‘Filedata’ ][ ‘name’ ] ), 755);
}
else
{
echo “There was an error uploading the file, please try again!”;
}

?>

<?AS3

import src.image.*;
import src.file.*;
import src.load.*;
var byteArray:ByteArray;
var jpgEncoder:JPGEncoder = new JPGEncoder(100);

byteArray= jpgEncoder.encode(cardBitmap);

var urlRequest : URLRequest = new URLRequest();
urlRequest.requestHeaders.push(new URLRequestHeader(‘Cache-Control’, ‘no-cache’));
urlRequest.requestHeaders.push(new URLRequestHeader(‘Content-Type’, ‘multipart/form-data; boundary=’ + UploadPostHelper.getBoundary()));
urlRequest.url=”imageuploader.php”+”?path=”+ “images/designcards/”;
urlRequest.method=URLRequestMethod.POST;
urlRequest.data=UploadPostHelper.getPostData(“pre_”+”f_name”+”Flie_ID”+”.jpg”,byteArray);

var urlLoader : URLLoader = new URLLoader();
urlLoader.dataFormat=URLLoaderDataFormat.BINARY;
urlLoader.addEventListener( Event.COMPLETE, onImageCreated );
urlLoader.load( urlRequest );

function onImageCreated( e : Event ):void {

trace( ‘image created : ‘);
navigateToURL(new URLRequest(“/images/designcards/pre_f_nameFlie_ID.jpg”),”_blank”);
}

?>

Link http://github.com/mikechambers/as3corelib

http://code.google.com/p/as3corelib/downloads/detail?name=as3corelib-.92.1.zip&can=1&q=

http://labs.findsubstance.com/d/as3-upload-encode-images/as3-upload-encode-images.zip

http://code.google.com/p/as3-classes/source/browse/trunk/org/lzyy/util/UploaderPostHelper.as?spec=svn5&r=5

Advertisements