public function upload() { if (!isset($_FILES)) { return; } $errors = array(); $file_info = array(); if (is_array($_FILES['file']['name'])) { $images = \CODOF\Util::re_array_files($_FILES['file']); } else { $images = array($_FILES['file']); } foreach ($images as $image) { if (!\CODOF\File\Upload::valid($image) or !\CODOF\File\Upload::not_empty($image) or !\CODOF\File\Upload::size($image, (int) \CODOF\Util::get_opt('forum_attachments_size')) or !\CODOF\File\Upload::type($image, explode(",", \CODOF\Util::get_opt('forum_attachments_exts')))) { $errors[] = "Error While uploading the image."; } else { $ext = strtolower(pathinfo($image['name'], PATHINFO_EXTENSION)); $file_info[] = \CODOF\File\Upload::save($image, uniqid() . "." . $ext, DATA_PATH . \CODOF\Util::get_opt('forum_attachments_path'), 0777); } } echo json_encode($file_info); }