function contact_attach_contact_form_validate in Contact Attach 7
Form validation handler for contact_site_form() and contact_personal_form().
Validates the attachments.
See also
contact_attach_contact_site_form_submit()
contact_attach_contact_personal_form_submit()
1 string reference to 'contact_attach_contact_form_validate'
- contact_attach_form_alter in ./
contact_attach.module - Implements hook_form_alter().
File
- ./
contact_attach.module, line 168 - Allows attaching files to messages sent using contact forms.
Code
function contact_attach_contact_form_validate($form, &$form_state) {
$validators = array(
'file_validate_extensions' => array(
$form_state['values']['allowed_extensions'],
),
'file_validate_size' => array(
$form_state['values']['file_size_limit'],
),
);
// Loop through each possible attachment.
foreach ($_FILES['files']['name'] as $temp_name => $file_name) {
$file = file_save_upload($temp_name, $validators);
if ($file === FALSE) {
form_set_error($temp_name, t('Failed to attach the file %name.', array(
'%name' => $file_name,
)));
}
}
}