Skip to content

Commit b6cdd52

Browse files
committed
add config for filename check, update documents, fix issue #50
1 parent 42235c5 commit b6cdd52

File tree

6 files changed

+24
-4
lines changed

6 files changed

+24
-4
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ PR is welcome!
2222
1. [Config](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/config.md)
2323
1. [Customization](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/customization.md)
2424

25+
## Upgrade guide
26+
* `composer update unisharp/laravel-filemanager`
27+
* `php artisan vendor:publish --tag=lfm_view --force`
28+
* `php artisan vendor:publish --tag=lfm_config --force`(remember to keep your previous settings in `config/lfm.php`)
29+
2530
## Screenshots
31+
* Independent usage example :
2632
![Independent usage example](http://unisharp.github.io/images/lfm01.png)
33+
* List view :
2734
![FileManager screenshot 1](http://unisharp.com/img/filemanager1.png)
35+
* Grid view :
2836
![FileManager screenshot 2](http://unisharp.com/img/filemanager2.png)
2937

3038
## Credits

doc/config.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ In `config/lfm.php` :
1414
// true : files will be renamed as uniqid
1515
// false : files will remain original names
1616

17+
// true : filter filename characters which are not English or numbers, and replace them with '_'
18+
'check_filename' => true,
19+
1720
'use_package_routes' => true,
1821
// set this to false to customize route for file manager
1922

doc/customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Feel free to customize the routes and views if your need.
1111

1212
### Routes
1313

14-
1. Copy the routes in src/routes.php
14+
1. Copy the routes in /vendor/unisharp/laravel-filemanager/src/routes.php
1515

1616
1. Make sure urls below is correspond to your route :
1717

src/config/lfm.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// If true, the uploaded file will be renamed to uniqid() + file extension.
55
'rename_file' => true,
66

7+
// If rename_file set to false and this set to true, then filter filename characters which are not English or numbers.
8+
'check_filename' => true,
9+
710
'use_package_routes' => true,
811

912
// For laravel 5.2, please set to ['web', 'auth']

src/controllers/LfmController.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct()
4949
public function show()
5050
{
5151
$working_dir = '/';
52-
$working_dir .= (Config::get('lfm.allow_multi_user')) ? \Auth::user()->user_field : Config::get('lfm.shared_folder_name');
52+
$working_dir .= (Config::get('lfm.allow_multi_user')) ? $this->getUserSlug() : Config::get('lfm.shared_folder_name');
5353

5454
return view('laravel-filemanager::index')
5555
->with('working_dir', $working_dir)
@@ -81,7 +81,7 @@ private function formatLocation($location, $type = null, $get_thumb = false)
8181
if ($type === 'share') {
8282
return $location . Config::get('lfm.shared_folder_name');
8383
} elseif ($type === 'user') {
84-
return $location . \Auth::user()->user_field;
84+
return $location . $this->getUserSlug();
8585
}
8686

8787
$working_dir = Input::get('working_dir');
@@ -115,6 +115,12 @@ private function formatLocation($location, $type = null, $get_thumb = false)
115115
****************************/
116116

117117

118+
public function getUserSlug()
119+
{
120+
return empty(auth()->user()) ? '' : \Auth::user()->user_field;
121+
}
122+
123+
118124
public function getPath($type = null, $get_thumb = false)
119125
{
120126
$path = base_path() . '/' . $this->file_location;

src/controllers/UploadController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private function getNewName($file)
104104

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

0 commit comments

Comments
 (0)