Check file size before download

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Check file size before download

Guest-170
Hi Dean,

Thanks for making your control free.  It been working great so far, just wanted to know if there is a way to check for the file size before download programatically.  I looked at the doc under "Limiting the Size of Upload Requests" but I what I'm trying to do with my solution is to check for the file size before download as the size will be different based on the person trying to upload a file.  Any ideas on how this can be done would be greatly appreciated.  Thanks again.

John.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Check file size before download

Dean Brettle
Administrator
I assume you meant to say "upload" instead of "download". :-)

There is no way to check the file size before the upload has started because Javascript doesn't have that capability.  However, the server can check the total size of the upload request (which would include the total size of all files being uploaded) as soon as the upload starts and it can stop the upload more or less immediately as described in "Limiting the Size of Upload Requests".  Programmatically changing that limitwould involve Creating a Custom UploadStorageProvider that compares the size of the upload to a size specified by Configuring Individual InputFile Controls Programmatically and throwing an exception if it is too large.  That shouldn't be particularly difficult if there is only one file per postback.  In that case you can just inherit from FilesystemUploadStorageProvider and put the logic in the CreateUploadedFile() method.


--Dean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Check file size before download

Guest-170
Thanks Dean,

I was working late last night and got my downloads and uploads mixed up, I will give it a shot.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Check file size before download

rlee923
In reply to this post by Dean Brettle
Hi Dean

Can we get more help on this? checking the file size?

I did read the manual but still don't understand it.

Could you give us some guides what to do?

Thanks.
Loading...