Am trying to upload files to google drive via curl in php leveraging this API Sample.Google Drive File Upload API
Here is my ssue:
When I run the code below. I got a successful message as per below but no file is uploaded to that folder.
Here is the Google API Response
string(121) "{ "kind": "drive#file", "id": "171bgh8-nDojxGjd_Fxxxxxxx", "name": "Untitled", "mimeType": "image/png" } "
Here is the code
$file_path = 'baby.png';
$folder_id = 'id of the folder goes here'; // ID of the folder you want to upload to
$mimetype= mime_content_type($file_path);
$filename= basename($file_path);
$headers = array(
"Authorization: Bearer $access_token",
"Content-Type: $mimetype"
);
$post_fields = json_encode(array(
'name' => basename($file_path),
'parents' => array($folder_id),
'metadata' => "{name :$filename};type=application/json;charset=UTF-8",
'file' => new CURLFile($file_path, $mimetype),
));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
please how do I get the file uploaded to that folder via folder ID..