Skip to content

Commit fc396b0

Browse files
committed
fix file upload
1 parent 5a8e244 commit fc396b0

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

src/controllers/FolderController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class FolderController extends LfmController {
2222
*/
2323
public function getFolders()
2424
{
25-
$dir_path = $this->file_location . \Auth::user()->user_field;
25+
$dir_path = parent::getPath();
2626
$directories = parent::getDirectories($dir_path);
2727

28-
$share_path = $this->file_location . Config::get('lfm.shared_folder_name');
28+
$share_path = parent::getPath('share');
2929
$shared_folders = parent::getDirectories($share_path);
3030

3131
return View::make('laravel-filemanager::tree')

src/controllers/ItemsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public function getItems()
2626
{
2727
$type = Input::get('type');
2828
$view = $this->getView($type);
29-
$path = $this->file_location . Input::get('working_dir');
29+
$path = parent::getPath();
3030

31-
$files = File::files(base_path($path));
31+
$files = File::files($path);
3232
$file_info = $this->getFileInfos($files, $type);
3333
$directories = parent::getDirectories($path);
3434
$thumb_url = parent::getUrl('thumb');
@@ -45,8 +45,8 @@ private function getFileInfos($files, $type = 'Images')
4545
foreach ($files as $key => $file) {
4646
$file_name = parent::getFileName($file);
4747
$file_created = filemtime($file);
48-
4948
$file_size = number_format((File::size($file) / 1024), 2, ".", "");
49+
5050
if ($file_size > 1024) {
5151
$file_size = number_format(($file_size / 1024), 2, ".", "") . " Mb";
5252
} else {

src/controllers/LfmController.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,25 @@ public function show()
5858

5959

6060
private function setPathAndType()
61-
{
61+
{
62+
// dd('type:'.Input::get('type'));
63+
6264
if (Input::has('type') && Input::get('type') === 'Files') {
6365
Session::put('lfm_type', 'Files');
64-
$this->file_location = Config::get('lfm.files_dir');
65-
$this->dir_location = Config::get('lfm.files_url');
66-
} else {
66+
Session::put('lfm.file_location', Config::get('lfm.files_dir'));
67+
Session::put('lfm.dir_location', Config::get('lfm.files_url'));
68+
} else if (Input::has('type') && Input::get('type') === 'Images') {
6769
Session::put('lfm_type', 'Images');
68-
$this->file_location = Config::get('lfm.images_dir');
69-
$this->dir_location = Config::get('lfm.images_url');
70+
Session::put('lfm.file_location', Config::get('lfm.images_dir'));
71+
Session::put('lfm.dir_location', Config::get('lfm.images_url'));
7072
}
7173
}
7274

7375

7476
private function checkMyFolderExists()
7577
{
7678
if (\Config::get('lfm.allow_multi_user') === true) {
77-
$path = base_path($this->file_location . Input::get('working_dir'));
79+
$path = $this->getPath();
7880

7981
if (!File::exists($path)) {
8082
File::makeDirectory($path, $mode = 0777, true, true);
@@ -85,7 +87,7 @@ private function checkMyFolderExists()
8587

8688
private function checkSharedFolderExists()
8789
{
88-
$path = base_path($this->file_location . Config::get('lfm.shared_folder_name'));
90+
$path = $this->getPath('share');
8991

9092
if (!File::exists($path)) {
9193
File::makeDirectory($path, $mode = 0777, true, true);
@@ -95,6 +97,10 @@ private function checkSharedFolderExists()
9597

9698
private function formatLocation($location, $type = null)
9799
{
100+
if ($type === 'share') {
101+
return $location . Config::get('lfm.shared_folder_name') . '/';
102+
}
103+
98104
$working_dir = Input::get('working_dir');
99105

100106
if ($working_dir !== '/') {
@@ -116,7 +122,7 @@ private function formatLocation($location, $type = null)
116122

117123
public function getPath($type = null)
118124
{
119-
$path = base_path() . '/' . $this->file_location;
125+
$path = base_path() . '/' . Session::get('lfm.file_location');
120126

121127
$path = $this->formatLocation($path, $type);
122128

@@ -126,7 +132,7 @@ public function getPath($type = null)
126132

127133
public function getUrl($type = null)
128134
{
129-
$url = $this->dir_location;
135+
$url = Session::get('lfm.dir_location');
130136

131137
$url = $this->formatLocation($url, $type);
132138

@@ -137,7 +143,7 @@ public function getUrl($type = null)
137143
public function getDirectories($path)
138144
{
139145
$thumb_folder_name = Config::get('lfm.thumb_folder_name');
140-
$all_directories = File::directories(base_path($path));
146+
$all_directories = File::directories($path);
141147

142148
$arr_dir = [];
143149

src/views/files.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636
<div class="col-sm-6 col-md-2 img-row">
3737

38-
<div class="thumbnail thumbnail-img text-center" style="border: none;" data-id="{{ $file_name }}" id="img_thumbnail_{{ $key }}">
39-
<i class="fa {{ $file['icon'] }} fa-5x" style="cursor:pointer;" onclick="useFile('{{ $file_name }}')"></i>
38+
<div class="thumbnail thumbnail-img text-center" data-id="{{ $file_name }}" id="img_thumbnail_{{ $key }}">
39+
<i class="fa {{ $file['icon'] }} fa-5x" style="height:200px;cursor:pointer;padding-top:60px;" onclick="useFile('{{ $file_name }}')"></i>
4040
</div>
4141

4242
<div class="caption text-center">

0 commit comments

Comments
 (0)