How can I limit the number of upload files programmatically? I need to limit the number of upload files programmatically because the max number of files is 10 or unlimited and I need 14 upload files. Is it possible? I found the Upload max files module, but my question is if it is possible, programmatically.

I have installed Drupal 6.
I assume you use filefield module for attachment, if so, use this:

/**
 * Implementation of hook_form_alter().
 */
function YOURMODULENAME_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'content_field_edit_form') {
    $form['field']['multiple']['#options'] = array(1 =&gt; t('Unlimited'), 0 =&gt; 1) + drupal_map_assoc(range(2, 14));
  }
}