Convert cURL to be used in php function Convert cURL to be used in php function curl curl

Convert cURL to be used in php function


Found the answer, i needed to json_encode the attributes array and then use new \CURLFile() function to create a file handle, it did NOT work with realpath()

$attributes = array('name'=>$fileName,'parent'=>array('id'=>$folderId));$file = new \CURLFile($filePath);$fields = array('attributes' => json_encode($attributes), 'file' => $file);$headers = array("Authorization: Bearer ".$accessToken);$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $uploadUrl);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);$result = curl_exec($ch);


Try this: art about sending files via post and curlib

-F option means you're sending a post Field with name and content. Content in this case is from File becasue you're using @ prefix