You are here

function transliteration_file_presave in Transliteration 7.3

Implements hook_file_presave().

File

./transliteration.module, line 230
Converts non-latin text to US-ASCII and sanitizes file names.

Code

function transliteration_file_presave($file) {

  // If an uploaded file had its name altered in transliteration_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.)
  if (!empty($_FILES['files']['name']) && variable_get('transliteration_file_uploads', TRUE) && !variable_get('transliteration_file_uploads_display_name', TRUE)) {
    $key = array_search($file->filename, $_FILES['files']['name']);
    if ($key !== FALSE && isset($_FILES['files']['orig_name'][$key])) {
      $file->filename = $_FILES['files']['orig_name'][$key];
    }
  }
}