PHP curl to upload an image to a URL

<? php header("Content-type:application/json"); function uploadimg($url,$data){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $headers[] = "User-Agent :Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3947.100 Safari/537.36"; curl_setopt($ch, CURLOPT_HTTPHEADER,$headers); return curl_exec($ch); curl_close($ch); } $data = array(' Upload Parameter '=> new CURLFile(realPath ('test.jpg')),); Echo uploadimg(' upload interface URL',$data); ? >

Author:TANKING