Prevent File Upload during an ajax call I have a form that includes a managed_file field as well as a data popup and select field.  When the user selects a date, an ajax call is made to populate the select field.  However, I noticed that each time the ajax call is made, the file is uploaded, causing multiple copies of the file to to exist (each subsequent file having a number appended to the .  If the user selects another date, the file is uploaded again. How do I prevent the file from being uploaded multiple times during the ajax call?

Here is my form code

function _timesdb_import_form($form,&amp;$form_state) {

  $form['file_fid'] = array(
    '#type' =&gt; 'managed_file',
    '#title' =&gt; 'Import File',
    '#size' =&gt; 100,
    '#description' =&gt; 'Select an import file.', 
      '#upload_location' =&gt; 'private://filelocation/',
      '#required' =&gt; true,
      '#default_value' =&gt; variable_get('file_fid',''),
    );
    $form['date'] = array(
      '#type' =&gt; 'date_popup',
      '#date_format' =&gt; 'm/d/Y',
      '#title' =&gt; 'Start Date',
      '#description' =&gt; 'Enter the start date of the meet. After changing the date, select the meet below',
      '#ajax' =&gt; array(
      'event' =&gt; 'change',
      'callback' =&gt; '_timesdb_import_meets_ajax',
      'wrapper' =&gt; 'timesdb-import-meets',
    ),
  );

  $meet_options = isset($form_state['values']['date']) ? _timesdb_import_get_meets($form_state['values']['date']) : array();
  $form['meet'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Select meet',
    '#options' =&gt; $meet_options,
    '#prefix' =&gt; '&lt;div id="timesdb-import-meets"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#default_value' =&gt; 'Submit'
  );
  return $form;
}


The ajax callback looks like this

function _timesdb_import_meets_ajax($form,&amp;$form_state) {
  return $form['meet'];
}
Drupal submits the entire form at every ajax call, I think you'd have to use hooks before submit, before send or similar to prevent it. Heres something to get you started. Or simply put the file field last or at least after the ajax form elements.

Disable all form elements when doing AJAX

Ideally drupal should allow you to specify what you want to submit. please share your solution if you figure it out.