Custom form multiple file upload with different extension I am working multi file upload functionality with different extensions(pdf,doc,png,jpg). 
Following code is working fine for multiple images upload. I would like to know how this code modify for different extension like doc, pdf, png,gif etc.

function mymodule_form($form, &amp;$form_state) {
    $form['file'] = array(
        '#type' =&gt; 'file',
        '#name' =&gt; 'files[]',
        '#title' =&gt; t('Upload some photos'),
        '#attributes' =&gt; array('multiple' =&gt; 'multiple'),
    );
    $form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Submit'),

    );
}

form mymodule_form_validate($form, &amp;$form_state) {
    //Save multiple files
    $num_files = count($_FILES['files']['name']);
    for ($i = 0; $i &lt; $num_files; $i++) {
        $file = file_save_upload($i, array(
            'file_validate_is_image' =&gt; array(),
            'file_validate_extensions' =&gt; array('png gif jpg jpeg'),
        ));
        if ($file) {
            if ($file = file_move($file, 'public://images')) {
                $form_state['values']['file'][$i] = $file;
            }
            else {
                form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.'));
            }
        }
        else {
            form_set_error('file', t('No file was uploaded.'));
        }   
    }
}
You can use '#type' => 'managed_file' instead of    '#type' => 'file'

managed_file types is powerful tools support any kind of files format with ajax upload.

example :
$form['file'] = array(
        '#type' => 'managed_file',
        '#name' => 'files[]',
        '#title' => t('Upload some photos'),
        '#attributes' => array('multiple' => 'multiple'),
    );

you can also add upload location of files like

'#upload_location' => 'public://myfiles/'

for more info.
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#managed_file