diff --git a/motorradig/app/Http/Controllers/GalleryController.php b/motorradig/app/Http/Controllers/GalleryController.php index 634f4eb..4b318aa 100644 --- a/motorradig/app/Http/Controllers/GalleryController.php +++ b/motorradig/app/Http/Controllers/GalleryController.php @@ -136,13 +136,31 @@ class GalleryController extends Controller //$file= new File(); //$file->filenames=json_encode($data); //$file->save(); - return redirect('/tour/index_old'); + return redirect("/tour/gallery/$tour_id"); } + public function delete_image($tour_id, $image_name) { + $image_name = explode(".", $image_name)[0]; + $files = [$image_name . ".jpg" , $image_name . "_gross.jpg"]; + $sourceDir = storage_path() . "/img_storage/tour-$tour_id"; + $targetDir = storage_path() . "/img_storage/tour-$tour_id-DELETED"; + + if (!file_exists($targetDir)) { + mkdir($targetDir, 0777, true); + } + + foreach($files as $file) { + rename("$sourceDir/$file", "$targetDir/$file"); + } + return redirect("/tour/gallery/$tour_id"); + + } /////////////////////////////////////////////////////////////////////////// private function storeImage($bild, $category, $name) { $cat=Str::slug($category); + + $name = explode(".",$name)[0]; $name=Str::slug($name); $dirPath = storage_path() . "/img_storage/$cat"; diff --git a/motorradig/resources/views/tour/gallery/show.blade.php b/motorradig/resources/views/tour/gallery/show.blade.php index f630b6d..5fc0433 100644 --- a/motorradig/resources/views/tour/gallery/show.blade.php +++ b/motorradig/resources/views/tour/gallery/show.blade.php @@ -6,19 +6,31 @@

{{$tour_name}}

-
- + + Try + + Me + + +

Hochladen

- @csrf + @csrf
diff --git a/motorradig/routes/web.php b/motorradig/routes/web.php index d816056..566fed4 100644 --- a/motorradig/routes/web.php +++ b/motorradig/routes/web.php @@ -65,7 +65,9 @@ Route::get('/tour/gallery/{gallery_id}', 'GalleryController@show'); // no middleware auth needed, its checked in Controller Route::post('/tour/gallery/{gallery_id}', 'GalleryController@store'); + Route::get('/tour/gallery/{gallery_id}/delete_image/{imageName}', 'GalleryController@delete_image'); + Auth::routes(); /* Cache clearing on remote server */ diff --git a/motorradig/storage/img_storage/tour-1/bildschirmfoto-vom-2023-02-03-14-43-07png.jpg b/motorradig/storage/img_storage/tour-1/bildschirmfoto-vom-2023-02-03-14-43-07png.jpg deleted file mode 100644 index 07427cb..0000000 Binary files a/motorradig/storage/img_storage/tour-1/bildschirmfoto-vom-2023-02-03-14-43-07png.jpg and /dev/null differ diff --git a/motorradig/storage/img_storage/tour-1/bildschirmfoto-vom-2023-02-03-14-43-07png_gross.jpg b/motorradig/storage/img_storage/tour-1/bildschirmfoto-vom-2023-02-03-14-43-07png_gross.jpg deleted file mode 100644 index 2d53a49..0000000 Binary files a/motorradig/storage/img_storage/tour-1/bildschirmfoto-vom-2023-02-03-14-43-07png_gross.jpg and /dev/null differ diff --git a/motorradig/storage/img_storage/tour-1/wer-montags-lacheltjpg.jpg b/motorradig/storage/img_storage/tour-1/wer-montags-lachelt.jpg similarity index 100% rename from motorradig/storage/img_storage/tour-1/wer-montags-lacheltjpg.jpg rename to motorradig/storage/img_storage/tour-1/wer-montags-lachelt.jpg diff --git a/motorradig/storage/img_storage/tour-1/wer-montags-lacheltjpg_gross.jpg b/motorradig/storage/img_storage/tour-1/wer-montags-lachelt_gross.jpg similarity index 100% rename from motorradig/storage/img_storage/tour-1/wer-montags-lacheltjpg_gross.jpg rename to motorradig/storage/img_storage/tour-1/wer-montags-lachelt_gross.jpg