form) { $newPath = Str::of(PublicFormController::FILE_UPLOAD_PATH)->replace('?', $this->form->id); if (Storage::exists($newPath.'/'.$value)) { return true; } } $fileNameParser = StorageFileNameParser::parse($value); if (! $uuid = $fileNameParser->uuid) { return false; } $filePath = PublicFormController::TMP_FILE_UPLOAD_PATH.$uuid; if (! Storage::exists($filePath)) { return false; } if (Storage::size($filePath) > $this->maxSize) { $this->error = 'File is too large.'; return false; } if (count($this->fileTypes) > 0) { $this->error = 'Incorrect file type. Allowed only: '.implode(',', $this->fileTypes); return collect($this->fileTypes)->map(function ($type) { return strtolower($type); })->contains(strtolower($fileNameParser->extension)); } return true; } public function message(): string { return $this->error; } }