diff --git a/hdz/app/Controllers/Api/Tickets.php b/hdz/app/Controllers/Api/Tickets.php index bf48626..08bb270 100644 --- a/hdz/app/Controllers/Api/Tickets.php +++ b/hdz/app/Controllers/Api/Tickets.php @@ -65,7 +65,9 @@ public function create() $validation->setRule('body','body','required',[ 'required' => lang('Api.error.bodyMissing') ]); - if($settings->config('ticket_attachment')){ + + $hasFiles = $this->request->getPost('attachment') !== null; + if($settings->config('ticket_attachment') && $hasFiles){ $max_size = $settings->config('ticket_file_size')*1024; $allowed_extensions = unserialize($settings->config('ticket_file_type')); $allowed_extensions = implode(',', $allowed_extensions); @@ -77,7 +79,7 @@ public function create() if($validation->withRequest($this->request)->run() == false){ return $api->output(implode(' ',array_values($validation->getErrors())), true); } - if ($settings->config('ticket_attachment')) { + if ($settings->config('ticket_attachment') && $hasFiles) { if ($files_uploaded = $attachments->ticketUpload()) { $files = $files_uploaded; } @@ -222,4 +224,4 @@ public function delete($id = null) $tickets->deleteTicket($id); return $api->output(lang('Api.ticketRemoved')); } -} \ No newline at end of file +}