file_example_delete_directory_submit

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 file_example_delete_directory_submit($form, &$form_state)

Submit handler for directory deletion.

See also

file_unmanaged_delete_recursive()

Related topics

Code

examples/file_example/file_example.module, line 422

<?php
function file_example_delete_directory_submit($form, &$form_state) {
  $directory = $form_state['values']['directory_name'];

  $result = file_unmanaged_delete_recursive($directory);
  if (!$result) {
    drupal_set_message(t('Failed to delete %directory.', array('%directory' => $directory)), 'error');
  }
  else {
    drupal_set_message(t('Recursively deleted directory %directory.', array('%directory' => $directory)));
    $_SESSION['file_example_default_directory'] = $directory;
  }
}
?>