Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save krasnikovdev/cf199c63783d8516960c1b2d98a828c5 to your computer and use it in GitHub Desktop.
Save krasnikovdev/cf199c63783d8516960c1b2d98a828c5 to your computer and use it in GitHub Desktop.
<?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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment