free tutorials logo spacer
spacer
PHP
 
     
   
shaddow bottom left

Importance of MAX_FILE_SIZE when uploading files

In short, Use it, it is important.

How to use it

1- Make sure the hidden field <input type="hidden" name="MAX_FILE_SIZE" value="1048576"> appears before the file upload box (The form field of type "file")
2- The size is defined in Bytes
3- Make sure this is slightly less than the value in PHP.INI, it does not make sense to make it much smaller as it can be fooled, and you can waste the user's time by setting it to a larger value

 

1048576B = 1MB
10485760B = 10MB

 

the value in PHP.INI is the hard limit, this is not a security measure or anything and it can be fooled easily, but all modern browsers that i know of will send the html form data in the order they appear in the form.

So with this above the upload box, it will arrive to PHP before the file so that PHP can end execution and spare your visitor the time needed to upload a file that is sure to FAIL due to the limit

Also note that you can sometimes (depending on how much privilages you have on the server) set the hard limit within the page, or in an htaccess file

in an htaccess file you would do something similar to

php_value upload_max_filesize 10M
php_value post_max_size 12M


Your Name:

Subject:

Your Comment:


From: WczYHfPHuJcpovb
Subject: pxjVdMiVaQxFWljSQ
awegaw1.txt;2;5
From: Boog
Subject: zsCHvhVhOyN
Sueproir thinking demonstrated above. Thanks!