Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Translit non-latin (cyrillic etc.) names of uploadig files to latin with timestamp by modx cleanAlias()
//Привязывать к событию OnFileManagerUpload.
$currentdoc = $modx->newObject('modResource');
foreach($files as $file)
if($file['error'] == 0)
$pathInfo = pathinfo($file['name']);
$oldPath = $directory.$file['name'];
$newPath = date("Y-m-d-h-s-").$currentdoc->cleanAlias($pathInfo['filename']).'.'. $pathInfo['extension'];
$source->renameObject($oldPath, $newPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment