Hi all!
Moving from plain curl to the Laravel HTTP client I'm encountering an issue in the multiform. I'm trying to send this:
$payload = [
'data' => 'Belgium',
'file' => new \CURLFILE(Storage::disk('local')->path('public/xxxx/xxxx.file'))
];
In plain curl it's working flawless, but when I try to use the attach() helper on the HTTP client, it doesn't allow me to send the complete $payload. Which is necessary for the endpoint I'm posting to.
Can someone give me a direction?
Curl code:
curl_setopt_array($curl, array(
CURLOPT_URL => $path,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
'Accept: application/json, text/javascript, */*; q=0.01',
'Accept-Language: nl,en-US;q=0.7,en;q=0.3',
'Accept-Encoding: gzip, deflate, br',
'Referer: ' . $this->base_url . '/login',
'X-Requested-With: XMLHttpRequest',
'Csrf-Token: ' . Crypt::decrypt($token),
'Origin: $this->base_url',
'Connection: keep-alive',
'Cookie: ' . Crypt::decrypt($cookie),
),
));
$response = curl_exec($curl);
curl_close($curl);