📜  laravel flutter 将图像保存在数据中 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:05.030000             🧑  作者: Mango

代码示例1
public function uploadFile(Request $request) {
        if($request->hasFile('image')) {
            $name = time()."_".$request->file('image')->getClientOriginalName();
            $request->file('image')->move(public_path('images'), $name);
        }
        return response()->json([
            asset("images/$name"),
            201,
            'message' => asset("images/$name") ? 'Image saved' : 'Image failed to save'
        ]);
    }