<?php
 class vB_Api_Vb4_newattachment extends vB_Api { public function manageattach($posthash, $attachment) { $cleaner = vB::getCleaner(); $posthash = $cleaner->clean($posthash, vB_Cleaner::TYPE_STR); $attach = $cleaner->clean($attachment, vB_Cleaner::TYPE_FILE); $attachments = []; foreach ($attach as $key => $value) { for ($i = 0; $i < count($value); $i++) { $attachments[$i][$key] = $value[$i]; } } unset($attach); foreach ($attachments as $attachment) { $result = vB_Api::instance('content_attach')->upload($attachment); if (empty($result) || !empty($result['errors'])) { return vB_Library::instance('vb4_functions')->getErrorResponse($result); } vB_Library::instance('vb4_posthash')->addFiledataid($posthash, $result['filedataid']); } return ['response' => []]; } } 