As far as I know $_FILES["fieldname"]["size"]
contains the file size after the file has been uploaded.
In Perl, you can read the raw file data very easy chunk-wise and that way determine if the file is too big before it has been fully uploaded.
Is there an easy way to do just the same in PHP
?
You can change the max size in the php.ini
config file, but it will affect all your file uploads :
upload_max_filesize 10M
If you're using a .htaccess
file, you can also write like that :
php_value upload_max_filesize 10M
Take a look at the doc
You cannot reach the file on the client from the server without copying it. What you can do is inspect the file using javascript on the client side, and decide then whether to upload or not.
Basically, read your file into a FileReader, and check the size attribute.
https://stackoverflow.com/a/4307882/326154 has some good answers.