file('file'); if ($file && $file->isValid()) { $name = md5(uniqid()); $file->move(public_path() . '/upload/' . $name . '.' . $file->getUploadExtension()); $data = [ 'id' => $name, 'src' => $request->header('x-forwarded-proto') ?? 'http' . '://' . $request->host() . '/upload/' . $name . '.' . $file->getUploadExtension(), 'fileName' => $name ]; return json(retData($this->result::SUCCESS, 'upload success', $data)); } return json(retData($this->result::ERROR, 'file not found')); } }