The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Way to determin filesize before uploading ?

Hi,

I have a file upload script for my website and i need to check the filesize before its uploaded to the server. Is there anyway i can do it using Javascript on client side so both user/server do not waste their resources ?

Javascript can't see the file and server side processing can't access it until after it is uploaded. The best you can do before that is to limit the file size so that files above a certain limit can't be uploaded.

That is what i am doing right now...and this is what i am trying to avoid. User first uploads files which takes a bit of time and then after waiting they are told that the file they uploaded is big...and user gets mad.

I thought maybe there was some sort of technique to avoid this problem or something.