Download the PHP package ondrej-vrto/php-filename-sanitize without Composer
On this page you can find all versions of the php package ondrej-vrto/php-filename-sanitize. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ondrej-vrto/php-filename-sanitize
More information about ondrej-vrto/php-filename-sanitize
Files in ondrej-vrto/php-filename-sanitize
Package php-filename-sanitize
Short Description Removes all forbidden characters from the file name or path.
License MIT
Homepage https://github.com/OndrejVrto/php-filename-sanitize
Informations about the package php-filename-sanitize
Removes all forbidden characters from the file name
Do you store files from the user on the server? Will the uploaded file be accessible in the application via a URL address? Don't want to lose the original file name?
Want to avoid meaningless randomly generated names? This package will help you solve your problem.
Installation
You can install the package via composer:
Basic usage
What problems does the package try to eliminate?
- Replace special characters
- file system reserved
- control characters
- non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN
- URI reserved
- URL unsafe characters
- Reduce some consecutive characters (spaces, undescores, dashes, dots)
- Windows reserved names
- Lowercase for windows/unix interoperability
- Max filename length to 255 bytes
Examples
Strings are sanitized and soft slugged (in addition to dashes, dots are also used).
Advanced settings
Create instance
Directory features
Extension features
Prefix, suffix features
Default name if sanitized filename is empty
Disable conversion to lowercase letters
Custom separator
Warning: Changing the separator can sometimes lead to unwanted side effects. Individual separator characters are removed from the beginning and end of the file name and extension.
A combination of all functions together
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
- Ondrej Vrťo
- All Contributors
License
The MIT License (MIT). Please see License File for more information.