Answer the question
In order to leave comments, you need to log in
How to transliterate files and folders when uploading to the server?
Laravel 5
Using https://github.com/barryvdh/laravel-elfinder to upload files to server.
It is necessary to add the functionality that, when uploading files to the server, transliterated the Cyrillic alphabet in the names of files and folders.
As I see it:
You need to override the method that is responsible for copying/transferring or directing data about the file/file to subsequent processing, and use str_slug() for example
Who faced such a task?
Tell me where to dig. I want to do everything right. Not crutch.
I'm currently rummaging through \vendor\barryvdh
Answer the question
In order to leave comments, you need to log in
laravel-elfinder is done this way, I
attach part of the config
'options' => array(
'bind' => [
'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre ls.pre' => [
'Plugin.Normalizer.cmdPreprocess',
'Plugin.Sanitizer.cmdPreprocess'
],
'ls' => [
'Plugin.Normalizer.cmdPostprocess',
'Plugin.Sanitizer.cmdPostprocess'
],
'upload.presave' => [
'Plugin.AutoResize.onUpLoadPreSave',
'Plugin.Normalizer.onUpLoadPreSave',
'Plugin.Sanitizer.onUpLoadPreSave'
],
],
'plugin' => [
'Normalizer' => [
'enable' => true,
'targets' => ['\\','/',':','*','?','"','<','>','|',' '], // target chars
'replace' => '_', // replace to this
'convmap' => [
',' => '_',
'^' => '_',
"а" => "a",
"б" => "b",
"в" => "v",
"г" => "g",
"д" => "d",
"е" => "e",
"ё" => "e",
"ж" => "zh",
"з" => "z",
"и" => "i",
"й" => "j",
"к" => "k",
"л" => "l",
"м" => "m",
"н" => "n",
"о" => "o",
"п" => "p",
"р" => "r",
"с" => "s",
"т" => "t",
"у" => "u",
"ф" => "f",
"х" => "h",
"ц" => "ts",
"ч" => "ch",
"ш" => "sh",
"щ" => "shch",
"ы" => "y",
"э" => "e",
"ю" => "yu",
"я" => "ya",
"А" => "a",
"Б" => "b",
"В" => "v",
"Г" => "g",
"Д" => "d",
"Е" => "e",
"Ё" => "e",
"Ж" => "zh",
"З" => "z",
"И" => "i",
"Й" => "j",
"К" => "k",
"Л" => "l",
"М" => "m",
"Н" => "n",
"О" => "o",
"П" => "p",
"Р" => "r",
"С" => "s",
"Т" => "t",
"У" => "u",
"Ф" => "f",
"Х" => "h",
"Ц" => "ts",
"Ч" => "ch",
"Ш" => "sh",
"Щ" => "shch",
"Ы" => "y",
"Э" => "e",
"Ю" => "yu",
"Я" => "ya",
" " => "_"
]
],
],
),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question