how to validate file size in drupal file upload in here file validate extensions are working,but the file size validate is not working,i just need file size only, resolution doesn't matter,i want to restrict max file size to 1MB

 $form['photo']['file'] = array(
'#title' =&gt; t('Photo (Max size 2 MB)'),
'#type' =&gt; 'managed_file',
'#description' =&gt; t('xvxcds'),
'#default_value' =&gt; variable_get('photo', ''),
'#upload_location' =&gt; 'public://photo_images/',
 '#upload_validators' =&gt; array(
'file_validate_size' =&gt; array(1024*1280*800),
'file_validate_extensions' =&gt; array('gif jpg jpeg'),
// Pass the maximum file size in bytes
), );
You're currently setting the limit to 1024*1280*800 bytes, which is the equivalent of about 1Gb.

Remember, 1kb = 1024b, 1mb = 1024kb, so for a 1mb limit:

'file_validate_size' =&gt; array(1024 * 1024),