The only thing
AddDefaultCharset does is to add
charset=utf-8 to the HTTP header Content-type if the previous part is missing. Nothing to see with uploads or downloads.
On a Windows system, PHP functions relative to file system do not handle UTF-8 but ANSI code page (CP1252 for French) as PHP use ANSI functions and not Unicode functions (UTF-16) of Windows API.
IMO, in general, the best way to handle uploads is to generate unique file names and ignore client file names or, at least, ignore bytes >
$filename = filter_var($_FILES['upload']['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
Can it be possible to check whether the current locale supports for utf-8 just before iconv() statement?
You can use
setlocale (to get current locale
FALSE !== strpos(setlocale(LC_CTYPE, '0'), 'UTF-8') and/or returns
FALSE if it is unavaible
if (!setlocale(LC_CTYPE, 'fr_FR.UTF-8'))).
UPDATE: as of PHP 7.1.0, PHP can now use UTF-8 encoded paths on Windows (set internal_encoding to UTF-8, for example - should be the case by default).