lundi 5 février 2018

Sending image and data with guzzle and Laravel

I am performing a client management, and I want to pass the data as name, email, city, etc ... and an image, at a single time, what better method to do this?

I tried using this method

public function store(Request $request)
{
    $dataForm = $request->all();

    $Client = new Client();

    $response = $Client->post( config('constants.caminhoWS').'cliente', 
    [
        'multipart' => 
        [
            [
                'name'     => 'UploadIMG',
                'filename' => 'image_org',
                'Mime-Type'=> 'image_mime',
                'contents' => $request->file('UploadIMG'),
            ]
        ]

    ]);

    $response = $response->getBody()->getContents();
    return response()->json(['msg'=>$response]);

}

but this only loads the image, as I can also send the $dataForm?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire