📜  在请求正文 laravel 6 中发送图像 - PHP 代码示例

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

代码示例1
public function uploadTest(Request $request) {

    if(!$request->hasFile('image')) {
        return response()->json(['upload_file_not_found'], 400);
    }
    $file = $request->file('image');
    if(!$file->isValid()) {
        return response()->json(['invalid_file_upload'], 400);
    }
    $path = public_path() . '/uploads/images/store/';
    $file->move($path, $file->getClientOriginalName());
    return response()->json(compact('path'));
 }