소스 검색

check on imgs

FabioFratini 1 년 전
부모
커밋
a3f4b8d27a
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      app/Http/Livewire/Traits/HasAllegato.php

+ 11 - 0
app/Http/Livewire/Traits/HasAllegato.php

@@ -19,6 +19,7 @@ trait HasAllegato
     public $allegatiDocumenti;
     public $allegati = [];
 
+    protected $imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp'];
 
     public function getAllegatoType($type)
     {
@@ -43,6 +44,16 @@ trait HasAllegato
 
     public function saveAllegato()
     {
+        if ($this->allegatoGallery == 1) {
+            foreach ($this->allegatiFiles as $file) {
+                $extension = pathinfo($file, PATHINFO_EXTENSION);
+                if (!in_array(strtolower($extension), $this->imageExtensions)) {
+                    session()->flash('error', 'I File devono essere immagini per Tipologia: foto sinistro');
+                    return;
+                }
+            }
+        }
+
         $files = implode("|", $this->allegatiFiles);
 
         if ($this->allegatoId > 0) {