PHP: File access with umlauts under Windows

Files on web servers should always be without spaces (not "this is a picture.jpg"), without umlauts or special characters (not "football.jpg"), without backslashes (not "Arbeit \ Auto.jpg") and in lower case (not "" test.JPG "). Recently, however, I had to access and process a large number of files with any file name for a customer project.

Linux systems allow access to files with umlauts and special characters by default, so that no special features have to be considered here. It looks completely different on Windows systems: Here you have to use some tricks and tap into the COM interface. First of all, you include the required extension in php.ini

extension = php_com_dotnet.dll

one. Now the very helpful helper class WinfsUtf8 is used, which greatly simplifies access to the COM objects and maps almost all PHP functions that affect files. After integrating the file with


you have all possibilities of file access, for example you get


incorrectly false, whereas


returns true.