Skip to content

Commit 6fbcaa4

Browse files
committed
[FIX] Allow uploading media with special chars
The file system does not know about UTF-8 encoded files. Fix #90.
1 parent c767eab commit 6fbcaa4

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/codebird.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,18 +1091,20 @@ protected function _buildMultipart($method, $params)
10911091

10921092
// check for filenames
10931093
if (in_array($key, $possible_files)) {
1094+
// the file system does not know about UTF-8 filenames
1095+
$filename_decoded = utf8_decode($value);
10941096
if (// is it a file, a readable one?
1095-
@file_exists($value)
1096-
&& @is_readable($value)
1097+
@file_exists($filename_decoded)
1098+
&& @is_readable($filename_decoded)
10971099

10981100
// is it a valid image?
1099-
&& $data = @getimagesize($value)
1101+
&& $data = @getimagesize($filename_decoded)
11001102
) {
11011103
// is it a supported image format?
11021104
if (in_array($data[2], $this->_supported_media_files)) {
11031105
// try to read the file
11041106
ob_start();
1105-
readfile($value);
1107+
readfile($filename_decoded);
11061108
$data = ob_get_contents();
11071109
ob_end_clean();
11081110
if (strlen($data) === 0) {

0 commit comments

Comments
 (0)