| 5 fileupload.module | fileupload_validate(&$node) |
Implementation of hook_validate().
Verify that there is a file attached to the node.
File
- developer/
examples/ fileupload.module, line 162 - This is an example to demonstrate how to make a Drupal node support file uploads.
Code
function fileupload_validate(&$node) {
// Check for a new file upload.
if ($file = file_check_upload('file')) {
$node->file = $file;
}
// Make sure there is an upload or an existing file.
if (!$file && !file_exists($node->current_file)) {
form_set_error('file', t('A file must be provided.'));
}
}
Login or register to post comments