Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

francisMS's avatar

Image send to webservice using cURL CURLOPT_POSTFIELDS in laravel

I want send $bodydata and $imageData to the webservice using cURL CURLOPT_POSTFIELDS in laravel

Any one can help.

This is my code :

$postfields = array();
$postfields['bodydata '] = $bodydata ;
    $postfields['imageData '] = $imageData ;


    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);

    curl_close($ch)
0 likes
0 replies

Please or to participate in this conversation.