artgris / FileManagerBundle

FileManager is a simple Multilingual File Manager Bundle for Symfony

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Removal of special characters from folder and file names

twin-elements opened this issue · comments

Hi.
I need to be able to remove special characters and spaces when creating a new folder or a new file. Unfortunately, in Poland, some servers have a problem with paths that contain Polish characters. How can I do this?

hey @twin-elements , did you find a way to do it?

Hi @rmekni
The only quick solution is to overwrite the controller and block a current version of the package in composer.json.
I will try to finish the modification to this manager soon and propose the changes to @artgris

thanks @twin-elements for your reply,
For me, for files, just overrided the main controller uploadFileAction and UploadHandler's trim_file_name function to remove special chars, for folders, indexAction of the main controller, i created a helper that creates a yaml file that contains the original name and the filtered one then i just search for the original name for manager but i keep the filtered one for the web url

There are already some events available in the bundle where you can handle such things for some cases.
The one I don't see is for directories, you might want to create a PR where you dispatch an event at

$directory = $directorytmp = $fileManager->getCurrentPath().\DIRECTORY_SEPARATOR.$data['name'];

And add a new event to https://github.com/artgris/FileManagerBundle/blob/master/Event/FileManagerEvents.php called PRE_CREATE_FOLDER

In your own application you can listen for this event and adjust the characters as required.