function up() { $petId = $_REQUEST['pet_id']; $nameType = empty($_REQUEST['name_type']) ? 0 : $_REQUEST['name_type']; $dirPath = ROOT . '/' . FILEPATH; // 文件夹路径 $fileName = getFilename($petId); // 检测参数是否完成 if (!isset($petId) || empty($petId) || !isset($_FILES['image']['name']) || empty($_FILES['image']['name'])) { return showReturn('上传参数错误'); } if (!is_dir($dirPath)) { mk_dir($dirPath); // 文件夹不存在创建 } // 上传文件 $fileName = upload($_FILES['image'], $dirPath, 'jpg,gif,png', 5, $fileName); // 检测上传后文件是否存在。不存在便错误 if (!file_exists($dirPath . $fileName)) { return showReturn('上传文件错误'); } return showReturn('ok', TRUE, 'json', $fileName); }
case 'scoreRec': showScore($smarty, $userInfo, $db); break; case 'report': showReport($smarty, $userInfo, $db); break; case 'submitReport': if (isset($_POST['brokenType']) && isset($_POST['desciption'])) { $db->report($userInfo['ID'], $_POST['brokenType'], $_POST['desciption']); showTip($smarty, "报告成功,感谢您的配合!", $db); } else { showError($smarty, '请正确报告问题!', $db); } break; case 'return': showReturn($smarty, $userInfo, $db); break; case 'returnTo': if (isset($_GET['s'])) { showConfirmReturn($smarty, $userInfo, $db); } else { showError($smarty, '请正确归还车辆!', $db); } break; case 'returnIt': if (isset($_GET['s']) && isset($_POST['code'])) { $stop = $db->getAllByID("tstop", $_GET['s']); if (test_auth($stop['code'], $db, $_POST['code'])) { showReturned($smarty, $userInfo, $db); } else { showError($smarty, '车站口令错误,请重试!', $db);