Solution 1 :

please convert to base 64,

$photoPath = 'folder/path.jpg';
$getExtension = explode(".",$photoPath);
 $base64 = 'data:image/'.$getExtension[1].';base64,'.file_get_contents($photoPath);
 $data = json_encode(array(
    'chatId'=>$phone.'@c.us',
    'body'=>  $base64,  //how can i make my local image to this URL 
    'filename'=>$file_name,
    'caption'=> $caption
));

Problem :

I am trying to send image in whatsApp chat by using Chat API,

by reference: https://blog.chat-api.com/manuals_and_tutorials/api_whatsapp_send_file_php/

in this case the code is like this:

$data = json_encode(array(
    'chatId'=>$phone.'@c.us',
    'body'=>'URL of the image',     
    'filename'=>'picture.jpg',
    'caption'=>'Hey! There is a file!'
));

I am sending chartId,filename and caption from the html form,My html form like this:

<?php 
    if(isset($_POST['submit'])){

       $apiURL = 'api.chat-api.com/instanceXXXXX/';
       $token = 'abcdefgABCDEFG';

        $phone = $_POST['phone_no'];
        $file_name = $_POST['file_name'];
        $caption = $_POST['caption'];
    
  
   $data = json_encode(array(
    'chatId'=>$phone.'@c.us',
    'body'=>'URL of the image',  //how can i make my local image to this URL 
    'filename'=>$file_name,
    'caption'=> $caption
));

     $url = $apiURL.'sendFile?token='.$token;
     $options = stream_context_create(['http' => [
           'method'  => 'POST',
           'header'  => 'Content-type: application/json',
            'content' => $data
        ]
     ]);
     $response = file_get_contents($url,false,$options);
     echo $response; exit;
}
?>
<html>
<body>
<form action = '' method = ''>
   <input type = "text" name = "phone_no" id = "phone_no" />
   <img src = "#" name = "img" id = "img" /> // here local(from my desktop) image is i am displaying
   <input type = "text" name = "file_name" id = "file_name" />
   <input type = "text" name = "caption" id = "caption" />
   <input type = "submit" name = "submit" value =  "Send" />
</form>
</body>
</html>

Here my problem is how can I send my local image into chat,are we convert our local image to URL . I am not understanding help me on this.

It is appreciate .
Note that URL in $data like this: address of the image(https://test.com/PHP/picture.jpg)

By