I am using AsyncFileUpload in order to allow users to asynchronously upload files.
I want to limit the size of the file to 1MB.
So far as to what I've seen I can only get the length of the file upon upload completion
like when upload starts:
(OnClientUploadStarted)
function UploadStarted(sender,args)
{
//if bigger than 1MB (approximately)
if (args.get_length() > 1000000 )
{
ShowActionNotificationError( errorMessage);
return false;
}
}
args.get_length() is null , so I can't use it...
And when upload is completed:
(OnClientUploadComplete)
function UploadComplete(sender,args)
{
//if bigger than 1MB (approximately)
if (args.get_length() > 1000000 )
{
ShowActionNotificationError( errorMessage);
return false;
}
}
works ok, but file was already uploaded...
So How can I know the size of the file before uploading it? am I missing something very simple?
I would really like to do it without handling HTTP Request length and the sort.
Thanks!
You can do this in the client side Upload Start event.
if (sender._inputFile.files[0].size >= maxFileSize) {
sender._stopLoad();
}
_stopLoad will call your Upload Error event.
After some substantial research I realize this cannot be done using AJAX.
As I look around at sites like yahoo mail and gmail, it's done by Flash.
in hotmail it's done with Silverlight.
there is a free (for now) flash upload control called Uploadify...
I am now working on integrating it.
if I'm wrong please correct me! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With