Clear managed_file field on submit I'd like to clear the managed file field each time the contents are sent off for further processing on submit. 

The callbacks work fine, but I have repeatedly come unstuck in my goal of having a "fresh" form everytime I need to submit a new image.

The form is defined thus:

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

$form['Input type'] = array(
    '#type'=&gt;'fieldset',
    '#title'=&gt;'Upload your image'
);

$form['Input type']['file'] = array(
    //file left in non-permanent state for testing purposes
    '#type' =&gt; 'managed_file',
    '#title'=&gt; t('Upload image'),
    '#description' =&gt; t('Choose an image to upload. Format must be gif, png, jpg, and may not exceed 2MB in size. Press Submit to confirm your selection.'),
    '#upload_validators' =&gt; array(
        'file_validate_extensions' &gt; array('gif png jpg jpeg'),
        'file_validate_size'=&gt;array(512*512*512),
    ),
    '#upload_location'=&gt;'public://mymodule_uploads',
);

$form['Input type']['submit'] = array(
    '#type'=&gt;'submit',
    '#value' =&gt;t('Submit'),
    '#submit'=&gt;array('mymodule_clear_image_submit'),
    '#ajax' =&gt; array(
            'callback'=&gt; 'mymodule_update_image_callback',
            'wrapper'=&gt;'somediv'
        ),
);
return $form;
}
function mymodule_update_image_callback($form,&amp;$form_state) {
$picture_settings = array( 
        'image' =&gt; file_create_url($form['Input type']['file']['#file']-&gt;uri)
        );
    drupal_add_js(array('mymodule' =&gt; $picture_settings),'setting');

    return;
}

function mymodule_clear_image_submit($form,&amp;$form_state) {
$form_state['complete form']['Input type']['file']['#file'] = NULL;
$form_state['rebuild']=TRUE;
return;
}


Neither the submit nor the callback functions seems to be refreshing my form. Setting the file value to NULL has not had an effect either.

I don't know what else to try. Cheers!
I found a solution to this problem here: https://www.drupal.org/node/1578656

The idea is to add the following keys to the 'file_managed' field at the time you want to clear it:

$form[FORMKEY]['#file'] = FALSE;
$form[FORMKEY]['filename'] = array();
$form[FORMKEY]['#value']['fid'] = 0;


In your case it should be something like this in the form builder function:

if ( isset($form_state['storage']['reset-file-field'])
  &amp;&amp; $form_state['storage']['reset-file-field'] === true
) {
  $form['Input type']['file']['#file'] = FALSE;
  $form['Input type']['file']['filename'] = array();
  $form['Input type']['file']['#value']['fid'] = 0;

  $form_state['storage']['reset-file-field'] = false;
}


And then in your submit handler:

$form_state['storage']['reset-file-field'] = true;


The if-block is necessary to prevent the upload field being reset when you press 'upload', thus making it useless.