note 39654 modified in features.file-upload by vrana

From: Date: Tue, 17 Aug 2004 13:55:38 +0000
Subject: note 39654 modified in features.file-upload by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-80018@lists.php.net to get a copy of this message
when you upload the file, $_FILES['file']['name'] contains its original name converted into server's default charset. if a name contain characters that aren't present in default charset, the conversion fails and the $_FILES['file']['name'] remains in original charset. i've got this behavior when uploading from a windows-1251 environment into koi8-r. if a filename has the number sign "¹" (0xb9), it DOES NOT GET CONVERTED as soon as there is no such character in koi8-r. Workaround i use: <?php if (strstr ($_FILES['file']['name'], chr(0xb9)) != "") { $_FILES['file']['name'] = iconv ( "windows-1251", "koi8-r", str_replace (chr(0xb9), "N.", $_FILES['file']['name'])); }; ?> --was-- when you upload the file, $_FILES['file']['name'] contains its original name converted into server's default charset. if a name contain characters that aren't present in default charset, the conversion fails and the $_FILES['file']['name'] remains in original charset. i've got this behavior when uploading from a windows-1251 environment into koi8-r. if a filename has the number sign "¹" (0xb9), it DOES NOT GET CONVERTED as soon as there is no such character in koi8-r. Workaround i use: if (strstr ($_FILES['file']['name'], chr(0xb9)) != "") { $_FILES['file']['name'] = iconv ( "windows-1251", "koi8-r", str_replace (chr(0xb9), "N.", $_FILES['file']['name'])); }; http://php.net/manual/en/features.file-upload.php

« previous php.notes (#80018) next »