Created
March 29, 2018 17:38
-
-
Save krasnikovdev/cf199c63783d8516960c1b2d98a828c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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