You are here

function block_upload_deletefiles in Block Upload 7

Deletes files marked by checkbox in deletion form.

2 calls to block_upload_deletefiles()
block_upload_form_submit in ./block_upload.module
Save uploaded file to node.
block_upload_plupload_form_submit in ./block_upload.module
Saves files uploaded via plupload form.

File

./block_upload.module, line 393
Block Upload module.

Code

function block_upload_deletefiles($node, $field_name, &$form_state) {
  $delete_files = array_values($form_state['input']['remove_files']);
  foreach ($node->{$field_name}[LANGUAGE_NONE] as $key => $file_field) {
    if (in_array($file_field['fid'], $delete_files)) {
      $old_file = file_load($file_field['fid']);
      file_delete($old_file, TRUE);
      unset($node->{$field_name}[LANGUAGE_NONE][$key]);
    }
  }
  drupal_set_message(t('File(s) was successfully deleted!'));
}