file->validate(['size' => 4 * 1024 * 1024, 'ext' => 'jpg,jpeg,png,gif']) ->move($uplodDir, $this->fileName); if (empty($info)) { $this->error = $this->file->getError(); return false; } return true; } /** * 删除文件 * @param $fileName * @return bool|mixed */ public function delete($fileName) { // 文件所在目录 $filePath = WEB_PATH . "uploads/{$fileName}"; return !file_exists($filePath) ?: unlink($filePath); } /** * 返回文件路径 * @return mixed */ public function getFileName() { return $this->fileName; } }