Skip to content

Commit

Permalink
Fix file manager controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Sep 30, 2024
1 parent 2d208a4 commit 5bd0cf0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/Controllers/FileManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class FileManagerController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
public function index()
{

$mode = $request->get('mode');
$mode = request()->get('mode');

$current_dir = str_replace_first("storage/", "", $request->get('path') == null ? "" : ltrim($request->get('path'), "/"));
$current_dir = str_replace_first("storage/", "", request()->get('path') == null ? "" : ltrim(request()->get('path'), "/"));

$data = [
'old_path' => ($current_dir == "" ? "" : $current_dir . "/"),
Expand All @@ -37,7 +37,7 @@ public function index(Request $request)
];


if ($request->ajax()) {
if (request()->ajax()) {
return response()->json($data);
}

Expand All @@ -49,36 +49,36 @@ public function index(Request $request)
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
public function store()
{
if ($request->isMethod('POST')) {
if (request()->isMethod('POST')) {

if ($request->hasFile('up_file')) {
if (request()->hasFile('up_file')) {

$dir = str_replace("storage/", "", $request->input('dir_path'));
$dir = str_replace("storage/", "", request()->input('dir_path'));

foreach ($request->up_file as $file) {
foreach (request()->up_file as $file) {
if (!\Security::isExecutable($file)) {
$images[] = $file->store($dir);
}
}

if ($request->ajax()) {
if (request()->ajax()) {
return response()->json(['success' => 'Files uploaded successfully!', 'uploadedFileNames' => $images]);
}

return redirect()->back()->withMessage(['success' => 'Files uploaded successfully!']);
} else {

if ($request->ajax()) {
if (request()->ajax()) {
return response()->json(['danger' => 'Could not upload files!']);
}

return redirect()->back()->withMessage(['danger' => 'Could not upload files!']);
}
}

if ($request->ajax()) {
if (request()->ajax()) {
return response()->json(['warning' => 'Only POST method allowed!']);
}

Expand Down

0 comments on commit 5bd0cf0

Please sign in to comment.