From d02aa7e9233bafc10a26599667b8554cb1ea021d Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Wed, 10 Jan 2018 23:58:06 -0500 Subject: [PATCH] Clean up some things in the dashboard controller and put image uploads into an img subfolder --- app/Http/Controllers/DashboardController.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 64d31b5..1ffa40e 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -104,7 +104,7 @@ class DashboardController extends Controller { public function postImageUpload(Request $request) { if ($request->hasFile('file')) { - $file = base_path() . '/public/uploads/' . $request['model'] . '/' . $request['id'] . '.jpg'; + $file = base_path() . '/public/uploads/' . $request['model'] . '/img/' . $request['id'] . '.jpg'; $image = Image::make($request->file('file')); $image->save($file); } else { @@ -200,11 +200,10 @@ class DashboardController extends Controller { } // delete the associated image if one exists - $image_file = base_path() . '/public/uploads/' . $request['model'] . '/' . $request['id'] . '.jpg'; - if (file_exists($image_file)) { - if (!unlink($image_file)) { - return 'image-delete-fail'; - } + $image_file = base_path() . '/public/uploads/' . $request['model'] . '/img/' . $request['id'] . '.jpg'; + + if (file_exists($image_file) && !unlink($image_file)) { + return 'image-delete-fail'; } // Return a success