]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/Images/GalleryImageController.php
Merge pull request #4193 from BookStackApp/custom_dropzone
[bookstack] / app / Http / Controllers / Images / GalleryImageController.php
index 5484411d36c4208da2055e37d9e5335689c8270a..c01eccfee30193a5fc95f85f5a2630e190846569 100644 (file)
@@ -10,14 +10,9 @@ use Illuminate\Validation\ValidationException;
 
 class GalleryImageController extends Controller
 {
-    protected $imageRepo;
-
-    /**
-     * GalleryImageController constructor.
-     */
-    public function __construct(ImageRepo $imageRepo)
-    {
-        $this->imageRepo = $imageRepo;
+    public function __construct(
+        protected ImageRepo $imageRepo
+    ) {
     }
 
     /**
@@ -47,9 +42,14 @@ class GalleryImageController extends Controller
     public function create(Request $request)
     {
         $this->checkPermission('image-create-all');
-        $this->validate($request, [
-            'file' => $this->getImageValidationRules(),
-        ]);
+
+        try {
+            $this->validate($request, [
+                'file' => $this->getImageValidationRules(),
+            ]);
+        } catch (ValidationException $exception) {
+            return $this->jsonError(implode("\n", $exception->errors()['file']));
+        }
 
         try {
             $imageUpload = $request->file('file');