hasFile('file')) Yo::error_echo(200024); $file = $request->file('file'); $type = $request->post('type') ?? 'public'; if (!$file->isValid()) Yo::error_echo(200024); $date = date('Y/m'); $filename = Str::orderedUuid() . '.' . $file->getClientOriginalExtension(); if ($type == 'forbidden') { $file->storeAs("forbidden/$date", $filename); $url = "/storage/app/forbidden/$date/$filename"; } else if ($type == 'h5txt') { $filename = $file->getClientOriginalName(); $file->move(public_path(), $filename); $url = "/$filename"; } else { $file->storeAs("public/assets/upload/file/$date", $filename); $url = "/storage/assets/upload/file/$date/$filename"; } return Yo::echo([ 'url' => $url ]); } public function image() { $base64 = request()->post('base64'); if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64, $result)) { $type = ['png', 'jpeg', 'jpg', 'gif']; if (!in_array($result[2], $type)) Yo::error_echo(100027); $disk = Storage::disk('public'); $name = Str::orderedUuid(); $date = date('Y/m'); $path = "/assets/upload/image/$date/$name.$result[2]"; $put = $disk->put($path, base64_decode(str_replace($result[1], '', $base64))); if (!$put) Yo::error_echo(100028, ['put']); $save = "/storage/assets/upload/image/$date/$name.$result[2]"; return Yo::echo([ 'url' => $save ]); } else { Yo::error_echo(100028, ['base64']); } } }