Why is the MAX_FILE_SIZE for an HTML <input type="file">
always in uppercase?
All examples I've seen do this. Why?
Is this something historical / are there lots of examples on the web which doesn'开发者_开发知识库t use uppercase which I just didn't see?
This is not an HTML feature, but a PHP feature.
The documentation explains how PHP looks for a field named MAX_FILE_SIZE
in form data, and uses its value for handling file uploads if applicable.
It's a matter of historical convention that constants are capitalised and, traditionally, a field like MAX_FILE_SIZE
would be a constant in an application. Matters are complicated slightly because, as far as PHP is concerned, it's actually a variable (named $_POST['MAX_FILE_SIZE']
) and isn't constant at all; still, if you take the web application as a whole, you could see how this convention might still apply.
It also sets the field name apart from any other fields that the user has in his/her form.
Note that, since access to arrays by string key is case-sensitive, it makes sense to assume that PHP's search for this form field is also case-sensitive. So, if you were considering otherwise, stick with the capitalisation.
Constant generally are always Uppercase. That's true for every language.
精彩评论