1 system.module system_file_presave(File $file)

Implements hook_file_presave().


core/modules/system/system.module, line 2221
Configuration system that lets administrators modify the workings of the site.


function system_file_presave(File $file) {
  // If an uploaded file had its name altered in system_init() and if
  // the human-readable display name is not being transliterated, restore the
  // original version as the human-readable name before saving. (The
  // transliterated version will still be used in the file URI, which is the
  // only place where it matters.)
  $config = config('system.core');
  if (!empty($_FILES['files']['name']) && $config->get('file_transliterate_uploads') && !$config->get('file_transliterate_uploads_display_name')) {
    $key = array_search($file->filename, $_FILES['files']['name']);
    if ($key !== FALSE && isset($_FILES['files']['orig_name'][$key])) {
      $file->filename = $_FILES['files']['orig_name'][$key];