fileupload_validate

Versions
4.6 – 5
fileupload_validate(&$node)

Code

developer/examples/fileupload.module, line 84

<?php
function fileupload_validate(&$node) {
  $error = array();

  // Check for a new file upload.
  if ($file = file_save_upload('file')) {
    $node->file = $file;
  }

  // Make sure there is a file upload, or an existing file in case of updates.
  if (!$node->file && !file_exists($node->filepath)) {
    $error['file'] = t('Missing file.');
  }

  return $error;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.