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' => t('Photo (Max size 2 MB)'),
'#type' => 'managed_file',
'#description' => t('xvxcds'),
'#default_value' => variable_get('photo', ''),
'#upload_location' => 'public://photo_images/',
 '#upload_validators' => array(
'file_validate_size' => array(1024*1280*800),
'file_validate_extensions' => array('gif jpg jpeg'),
// Pass the maximum file size in bytes
), );
share|improve this question

1 Answer

up vote 2 down vote accepted

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' => array(1024 * 1024),
share|improve this answer
thanks for answer...!! – Lasitha Kumara Gamage 2 days ago

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.