faqts : Computers : Programming : Languages : PHP : Not Quite PHP : Javascript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

54 of 154 people (35%) answered Yes
Recently 5 of 10 people (50%) answered Yes


How can I check the size of a file on the client side?
How can I limit the size of files uploaded to the server by a user?
Why when the uploaded file size exceeded the MAX_FILE_SIZE, the file size is set to 0 (using PHP 4.0

Jul 6th, 1999 05:10
Nathan Wallace, Christy Pang, Mitch Vincent, John Coggeshall

Javascript does not allow operations on files, and so it is not possible
to check the size of a file on the client side.
Most people checking the size of a file will want to do so before the
user uploads the file to their server.  You cannot actually do this
until the file upload is in progress.
You can put a MAXFILESIZE HTML tag in the <INPUT TYPE="file"> tag... Or
you can check the filesize once it's uploaded to PHP and simply not
process the upload if it's too big or too small (the file will be
automatically deleted after your script exits)....