Basically this is what's happening - this is not 100% accurate, but it's just a basic representation for illustrative purposes.
You've got a form, with some number of input fields:
<input type="text" name="foo" value="bar" />
<input type="file" name="somefile" />
<input type="text" name="baz" value="qux" />
When the form is submitted, browsers will convert the form fields/values into a string and send that string to the server:
foo=bar&somefile=contents of file here&baz=bux
0000000001111111111222222222233333333334444444
1234567890123456789012345678901234567890123456 -- character position
Let's say your post_max_size is 30 chars. That means PHP will process only this:
foo=bar&somefile=contents of f
So you'd end up with:
$_POST['foo'] = 'bar'
$_FILES['somefile'] => 'contents of f' + error = 3 - partial upload
Note that baz = qux
is nowhere to be seen - it was past the end of the chunk of data PHP did process, and is effectively lost.
if you rearranged your form so that the various text fields come first:
<input type="text" name="foo" value="bar" />
<input type="text" name="baz" value="qux" />
<input type="file" name="somefile" />
then on submission you'd get:
foo=bar&baz=qux&somefile=contents of file here
0000000001111111111222222222233333333334444444
1234567890123456789012345678901234567890123456
and with the same 30 char limit on POST size:
foo=bar&baz=qux&somefile=conte
producing
$_POST['foo'] = 'bar';
$_POST['baz'] = 'qux';
$_FILES['somefile'] = 'conte' + error = 3
The reality is more complex than this - a file upload will NOT appear in the posted data in this exact manner. A file upload uses a different body construction and form encoding semantics, but the end result is the same: You performed a POST that exceeded the maximum size PHP allows. Part of that POST got truncated, causing some of your form data to be lost.
" . $student_id;` - or using the one in http://stackoverflow.com/a/18568104/ while applying the same logic. – Funk Forty Niner Dec 10 '14 at 14:29