File upload field in CCK field settings Is there a difference in Drupal 7 to add a file-upload field on a "normal" form (i.e. a separate page for a modules' configuration) as opposed to the small settings area for a CCK field (the one that appears after clicking on the cog for the field you'd like to modify under the "Manage Display" tab)?

I have a bunch of configuration options for a custom field using hook_field_formatter_settings_form, but am stuck at trying to figure out how to create a file upload field. I'd ideally like to have the user able to browse for an image and upload it without having the page reload. This is all I currently have:

$element['custom_field_name']['image'] = array(
    '#type' =&gt; 'file',
    '#size' =&gt; 48,
    '#title' =&gt; t('Image upload'),
    '#description' =&gt; t("Upload an image."),
);


If it is possible to have a file upload field (that uses ajax) in this area, what else must I do?

Edit:

My file field now looks like this:

$element['custom_field_name']['image'] = array(
    '#type' =&gt; 'managed_file',
    '#title' =&gt; t('Image upload'),
    '#upload_validators' =&gt; array(
      'file_validate_extensions' =&gt; array(0 =&gt; 'png jpg jpeg gif'),
      'file_validate_image_resolution' =&gt; array('64x64', '10x10')
    ),
    '#upload_location' =&gt; 'public://default_images/',
    '#description' =&gt; t("Upload an image."),
);


This is sort of working: it allows me to upload a file and it goes to sites/default/files/default_images, but its only temporary. I've been going through the form api reference and it says I need to permanently save it. I am just unsure how where to put this logic. Do I add a #process key to my file field and call some private function? Or do I create a submit handler? The API reference doesn't go into as much detail as I'd like.
You need to add a FILE_STATUS_PERMANENT to the status of the file on form submit then save the file.

$file-&gt;status = FILE_STATUS_PERMANENT;
file_save($file);