self::CODE_FAIL_TO_UPLOAD_FILE, 'url' => '', 'msg' => T('fail to upload file')); if (!isset($_FILES['file'])) { $rs['code'] = self::CODE_MISS_UPLOAD_FILE; $rs['msg'] = T('miss upload file'); return $rs; } if ($_FILES["file"]["error"] > 0) { $rs['code'] = self::CODE_FAIL_TO_UPLOAD_FILE; $rs['msg'] = T('failed to upload file with error: {error}', array('error' => $_FILES['file']['error'])); DI()->logger->debug('failed to upload file with error: ' . $_FILES['file']['error']); return $rs; } $url = DI()->qiniu->uploadFile($_FILES['file']['tmp_name']); if (!empty($url)) { $rs['code'] = 0; $rs['url'] = $url; $rs['msg'] = ''; } @unlink($_FILES['file']['tmp_name']); return $rs; } }