You are here

function upload_js in Drupal 4

Same name and namespace in other branches
  1. 5 modules/upload/upload.module \upload_js()
  2. 6 modules/upload/upload.module \upload_js()

Menu-callback for JavaScript-based uploads.

1 string reference to 'upload_js'
upload_menu in modules/upload.module
Implementation of hook_menu().

File

modules/upload.module, line 774
File-handling and attaching files to nodes.

Code

function upload_js() {

  // We only do the upload.module part of the node validation process.
  $node = (object) $_POST['edit'];

  // Load existing node files.
  $node->files = upload_load($node);

  // Handle new uploads, and merge tmp files into node-files.
  _upload_prepare($node);
  _upload_validate($node);
  $form = _upload_form($node);
  foreach (module_implements('form_alter') as $module) {
    $function = $module . '_form_alter';
    $function('upload_js', $form);
  }
  $form = form_builder('upload_js', $form);
  $output = theme('status_messages') . form_render($form);

  // We send the updated file attachments form.
  print drupal_to_js(array(
    'status' => TRUE,
    'data' => $output,
  ));
  exit;
}