You are here

function filebrowser_form_upload_submit in Filebrowser 8

Same name and namespace in other branches
  1. 6.2 filebrowser.form.upload.inc \filebrowser_form_upload_submit()
  2. 7.4 filebrowser.module \filebrowser_form_upload_submit()
  3. 7.2 filebrowser.module \filebrowser_form_upload_submit()
  4. 7.3 filebrowser.module \filebrowser_form_upload_submit()

uploads submition.

1 string reference to 'filebrowser_form_upload_submit'
filebrowser_form_upload in ./filebrowser.module
upload form definition.

File

./filebrowser.module, line 564
Validates file path input on node form

Code

function filebrowser_form_upload_submit($form, &$form_state) {
  $i = 1;

  // Later we can have multi-upload
  $node = $form_state['values']['node'];
  $target = _filebrowser_build_new_upload_file_name($node, $form_state, $i);
  $success = copy($_FILES['files']['tmp_name']["file_{$i}"], $target);
  if (!$success) {
    drupal_set_message(t("Unable to upload this file, do you have filesystem right to do that ?"), 'error');
  }
  else {
    _filebrowser_load_files($node, NULL, TRUE);

    // force listing rebuild
    if (!empty($form['filebrowser_uploads']["description_{$i}"])) {
      $file = $node->file_listing[_filebrowser_safe_basename($target)];
      module_invoke_all('filebrowser_metadata_set', $file, array(
        'description' => $form_state['values']["description_{$i}"],
      ));
    }
  }
  drupal_goto("node/{$node->nid}/{$node->file_listing['.']['fid']}", _filebrowser_url_query());
}