public function invoke($arrInput) { if (!isset($arrInput['type_id']) || !isset($arrInput['title'])) { return '缺少参数'; } $type_id = intval($arrInput['type_id']); $title = $arrInput['title']; $data['type_id'] = $type_id; $data['name'] = $title; if ($type_id < 1) { return "type id 不能小于 0"; } $dataService = new Service_Data_Message_V2_MessageType(); $existType = $dataService->getTypeByTypeId($type_id); if ($existType) { return "type id {$type_id} [{$existType['name']}] 已经存在 "; } if ($_FILES['fileToUpload'] && $_FILES['fileToUpload']['error'] == 0) { if (strpos($_FILES['fileToUpload']['type'], 'image') !== 0) { return "上传文件不是图片"; } // 上传到百度云 $imgurl = Net_Util::uploadPic($_FILES['fileToUpload']); if ($imagurl === false) { return "图片上传百度云失败"; } $data['pic_url'] = $imgurl; } $ret = $dataService->addType($data); if ($ret === false) { return "保存失败"; } return "添加成功"; }