Skip to content

Commit 990bdee

Browse files
authored
Merge pull request #350 from khjay/fix-utf8filename
Fix utf8filename
2 parents d736d7d + fd19f34 commit 990bdee

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/controllers/RedirectController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RedirectController extends LfmController
1616
public function __construct()
1717
{
1818
$delimiter = config('lfm.prefix') . '/';
19-
$url = request()->url();
19+
$url = urldecode(request()->url());
2020
// dd($delimiter);
2121
$external_path = substr($url, strpos($url, $delimiter) + strlen($delimiter));
2222

src/controllers/UploadController.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ private function proceedSingleUpload($file)
6161
->save($new_file_path, 90);
6262

6363
$this->makeThumb($new_filename);
64-
} else {
64+
}
65+
{
6566
chmod($file->getRealPath(), 0644); // TODO configurable
6667
File::move($file->getRealPath(), $new_file_path);
6768
}
@@ -122,7 +123,7 @@ private function uploadValidator($file)
122123

123124
private function getNewName($file)
124125
{
125-
$new_filename = parent::translateFromUtf8(trim(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)));
126+
$new_filename = parent::translateFromUtf8(trim($this->_pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)));
126127

127128
if (config('lfm.rename_file') === true) {
128129
$new_filename = uniqid();
@@ -166,4 +167,19 @@ function getUrlParam(paramName) {
166167
if (o !== false) o.CKEDITOR.tools.callFunction(funcNum, '$file');
167168
</script>";
168169
}
170+
171+
private function _pathinfo($path, $options = null)
172+
{
173+
$path = urlencode($path);
174+
$parts = is_null($options) ? pathinfo($path) : pathinfo($path, $options);
175+
if (is_array($parts)) {
176+
foreach ($parts as $field => $value) {
177+
$parts[$field] = urldecode($value);
178+
}
179+
} else {
180+
$parts = urldecode($parts);
181+
}
182+
183+
return $parts;
184+
}
169185
}

0 commit comments

Comments
 (0)