The FileReference class has a size property. Before sending the file to the server, you can get the value of the property and check it against the max size you wish to allow package { import flash.display. *; import flash.net.
*; import flash.events. *; public class TestReference extends MovieClip { protected var maxSize = 600; public function TestReference():void { var ref:FileReference = new FileReference(); ref. AddEventListener(Event.
SELECT, onFileSelect); ref.browse(); } private function onFileSelect(e:Event):void { if (e.target. Size > maxSize) { // do some error handling } } } }.
The FileReference class has a size property. Before sending the file to the server, you can get the value of the property and check it against the max size you wish to allow. Package { import flash.display.
*; import flash.net. *; import flash.events. *; public class TestReference extends MovieClip { protected var maxSize = 600; public function TestReference():void { var ref:FileReference = new FileReference(); ref.
AddEventListener(Event. SELECT, onFileSelect); ref.browse(); } private function onFileSelect(e:Event):void { if (e.target. Size > maxSize) { // do some error handling } } } }.
I got it. Its done. Thanks.
– Fábio Antunes Oct 16 '09 at 10:28.
Check out the size property on FileReference to get the size of the file in bytes. When you call browse() on FileReference to pick the file, you can pass in an Array of FileFilter objects. This will let you restrict what types of files are allowed.
Great, I've managed to do the file filter, but I'm not sure how to do the size limiter. Can you help me with that? – Fábio Antunes Oct 15 '09 at 23:37 My thanks for also helping with the file filter.
– Fábio Antunes Oct 16 '09 at 10:31 After the user chooses a file, check the size. If it is too large, say that they must select a smaller file. You have no way of automatically filtering files that are too large from the upload dialog in the same way that you can filter out file types.
– joshtynjala Oct 19 '09 at 19:34.
I tried this: private var maxSize:Number = 300; private function uploadImageBtn_clickHandler() : void { var arr:Array = ; arr. Push(new FileFilter("Images", "*. Gif;*.
Jpeg;*. Jpg;*. Png")); fileRef.
Browse(arr); } private function fileReference_select(evt:Event):void { if (evt.target. Size > maxSize) { Alert. Show('Please choose a file under 300kb', 'File too large'); //tried here } else { fileRef.load(); } } But it tells me I can't invoke a file browse except from a mouse event.
So do I just tell users "try again", or can I simply re-present them with a browse dialog?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.