System settings form data access validation I have created system settings form for an image using managed_file.

$form['my_image'] = array(
  '#type' =&gt; 'managed_file',
  '#name' =&gt; 'Upload Image',
  '#title' =&gt; t('Upload Image'),
  '#default_value' =&gt; variable_get('my_image', ''),
  '#description' =&gt; t("Here you can upload setting image!"),
  '#upload_location' =&gt; 'public://my_image/',
  '#upload_validators' =&gt; array(
  'file_validate_extensions' =&gt; array('jpeg png svg jpg'),
  ),
  '#required' =&gt; TRUE,
);


How can I add the file view/download access on this file based on role?
It looks like the Field Permissions module is the answer to your case.

UPDATE: You could also use '#access' in your field definition, see this post