function block_upload_form_submit in Block Upload 7
Save uploaded file to node.
File
- ./
block_upload.module, line 297 - Block Upload module.
Code
function block_upload_form_submit($form, &$form_state) {
$values = $form_state['values'];
$nid = $values['block_upload_nid'];
$buid = $values['buid'];
$field_name = variable_get('block_upload_' . $buid . '_field', '');
$node = node_load($nid);
if (isset($form_state['input']['remove_files'])) {
if (array_filter($form_state['input']['remove_files'])) {
block_upload_deletefiles($node, $field_name, $form_state);
}
}
if (isset($form_state['storage']['file'])) {
$file = $form_state['storage']['file'];
if (isset($values['block_upload_' . $buid . '_alt'])) {
$file->alt = check_plain($values['block_upload_' . $buid . '_alt']);
}
if (isset($values['block_upload_' . $buid . '_title'])) {
$file->title = check_plain($values['block_upload_' . $buid . '_title']);
}
if (isset($values['block_upload_' . $buid . '_desc'])) {
$file->description = check_plain($values['block_upload_' . $buid . '_desc']);
}
$node->{$field_name}[LANGUAGE_NONE][] = (array) $file;
unset($form_state['storage']['file']);
drupal_set_message(t('File was successfully uploaded!'));
}
// Do not change existing path alias if pathauto module installed.
if (module_exists('pathauto')) {
$node->path['pathauto'] = FALSE;
}
node_save($node);
}