success('/uploads/1/20241019175205021482/7418af88ebc0333ef4bee0a0a2cc7de0.jpg'); $file = $request->file("file"); if (!$file->isValid()) { return $this->error(400, 'upload fail, code=' . $file->getUploadErrorCode()); } $now = date_create(); $savepath = sprintf("/uploads/%d/%s/%s", $request->admin->id, $now->format("YmdHisu"), $file->getUploadName()); $item = new Uploads(); $item->admin_id = $request->admin->id; $item->filesize = 0; $item->filepath = $savepath; $item->mime = $file->getUploadMimeType(); $item->create_at = $now->getTimestamp(); $file->move(public_path(). $savepath); $item->save(); return $this->success($savepath); } }