You are here

function imce_upload_form in IMCE 7

Same name and namespace in other branches
  1. 6.2 inc/imce.page.inc \imce_upload_form()
  2. 6 inc/page.inc \imce_upload_form()

Upload form.

2 string references to 'imce_upload_form'
imce_content in inc/imce.page.inc
Returns the content of the file browser.
imce_js_upload in inc/imce.js.inc
Ajax operation: upload.

File

inc/imce.page.inc, line 134
Implements the file browser.

Code

function imce_upload_form($form, &$form_state, $ref) {
  $imce =& $ref['imce'];
  $form['imce'] = array(
    '#type' => 'file',
    '#name' => 'files[]',
    '#title' => t('File'),
    '#size' => 30,
    '#attributes' => array(
      'multiple' => 'multiple',
    ),
  );
  if (!empty($imce['thumbnails'])) {
    $form['thumbnails'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Create thumbnails'),
      '#options' => imce_thumbnail_options($imce['thumbnails']),
    );
  }
  $replace = variable_get('imce_settings_replace', FILE_EXISTS_RENAME);

  // In case the user can decide, show options
  if ($replace == IMCE_RENAME_REPLACE) {
    $form['replace'] = array(
      '#type' => 'radios',
      '#title' => t('Behaviour for existing files'),
      '#default_value' => variable_get('imce_settings_replace', FILE_EXISTS_RENAME),
      '#options' => array(
        FILE_EXISTS_RENAME => t('Keep the existing file renaming the new one'),
        FILE_EXISTS_ERROR => t('Keep the existing file rejecting the new one'),
        FILE_EXISTS_REPLACE => t('Replace the existing file with the new one'),
      ),
    );
  }
  $form['upload'] = array(
    '#type' => 'submit',
    '#value' => t('Upload'),
    '#submit' => $imce['perm']['upload'] ? array(
      'imce_upload_submit',
    ) : NULL,
  );
  $form = array(
    'fset_upload' => array(
      '#type' => 'fieldset',
      '#title' => t('Upload file'),
    ) + $form,
  );
  $form['html_response'] = array(
    '#type' => 'hidden',
    '#default_value' => '1',
  );
  $form['#attributes']['enctype'] = 'multipart/form-data';
  $form['#action'] = $imce['url'];
  return $form;
}