Transliteration of files during upload

Transliteration of files during upload

Name: transfile

Event: OnFileManagerUpload

<?php switch ($modx->event->name) { case 'OnFileManagerUpload': $generator = $modx->newObject('modResource'); $bases = $source->getBases($directory); $fullPath = $bases['pathAbsolute'].ltrim($directory,'/'); $directory = $source->fileHandler->make($fullPath); foreach ($files as $file) { $ext = @pathinfo($file['name'],PATHINFO_EXTENSION); rename($directory->getPath().$file['name'], $directory->getPath() . str_replace($ext, $ext, $generator->cleanAlias($file['name']))); } break; default: break; } return true;
Fill out the brief and get an approximate development cost
Website Brief Logo brief Print brief