Skip to content

Commit 98a985a

Browse files
committed
Format filename after uploading
keep the Original file name, strip special characters and replace with _
1 parent 0e942fb commit 98a985a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/controllers/UploadController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ private function getNewName($file)
104104

105105
if (Config::get('lfm.rename_file') === true) {
106106
$new_filename = uniqid() . '.' . $file->getClientOriginalExtension();
107+
} else {
108+
$new_filename = preg_replace('/[^A-Za-z0-9\-\']/', '_', $file->getClientOriginalName()) . '.' . $file->getClientOriginalExtension();
107109
}
108110

109111
return $new_filename;

0 commit comments

Comments
 (0)