Image file upload in Flex with fixed size
May 5, 2007
hello guys this is some thing wht we use in almost every registration system which ask you for uploading the photo,in flex we can use this script whcih can restrict the size of image file and will upload the image on server….
the script goes like this.. everything is performed at client side.. so tht is better
public var fR:FileReference = new FileReference();
public var imageTypes:FileFilter = new FileFilter(“Images (*.jpg, *.jpeg, *.gif,
*.png)”, “*.jpg; *.jpeg; *.gif; *.png”);
public var image:Array = new Array(imageTypes);
public var request:URLRequest;
public function initApp():void
{
fR.addEventListener(Event.SELECT, selectHandler);
fR.addEventListener(Event.COMPLETE, completeHandler);
}
//call this function when you clck on browse button of your MXML
public function startUpload(eventObj:Event):void
{
registeredCtrl.photo.setFocus();
var success:Boolean = fR.browse(image);
request.url = “http://path to your folder on server”;
request.method = “POST”;
}
public function selectHandler():void
{
if(fR.size<=”size to be restricted”);
{
fR.upload(request, “file”, false);
}
}
public function completeHandler():void
{
//Action for further flow of program.
}
this is how we can upload image with size limitations in FLEX.
Entry Filed under: Flex. .
Trackback this post | Subscribe to the comments via RSS Feed