Form API image upload form and File Entity; images not listed in admin/content/file I used Form API to create an image upload form, where images get uploaded via managed_file. The upload process works just fine, but the uploaded files don't get listed in the admin/content/file overview that is provided by the File Entity Module. The overview only shows those files that were uploaded via file/add, File Entity's own upload form.

My code is:


/**
 * Create an image upload form
 */

function upload_form_image_form($form, &$form_state) {

  // Image file
  $form['image'] = array(
    '#type' => 'managed_file',
    '#name' => 'image',
    '#title' => t('Image file'),
    '#size' => 40,
    '#description' => t("Image should be in JPG format."),
    '#upload_location' => 'public://',
    '#required' => TRUE,
  );

  // Submit
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );

  return $form; 
}

/**
 * Submit the upload form and scale the image down to standard resolution
 */

function upload_form_image_form_submit($form, &$form_state) {
  if (isset($form_state['values']['image'])) {

    $image = file_load($form_state['values']['image']);

    $loadedimage = image_load($image->uri);
    list($width, $height) = getimagesize($image->uri);
    if ($width/$height >= 1) {
      image_scale($loadedimage, 900, null, $upscale = FALSE);
      }
    else {
      image_scale($loadedimage, null, 900, $upscale = FALSE);
      }

    image_save($loadedimage);
    $loadedimage->status = FILE_STATUS_PERMANENT;

  }
}
I think your problem is coming from calling image_save and not file_save. They are non synonymous so far as I can tell.

A managed_file is an uploaded file, and usually records an owner of the file with file_usage_add(). This is how drupal can manage whether the file is still needed by the system or can be unlinked or deleted when cron is run.

See this other drupal stackexchange answer on how to use the managed_file FAPI element. It should answer your question on how to get the (original) file saved. You could then create derivatives of the file with image processing as you've already successfully done; after the original file is saved.

I don't believe there is a streamlined solution for this in the file_entity module or in any image functions (I doubt it, as one thing is to upload and manage the file itself -- and another is to do proccessing on the image itself).