希望这是一个简单的...我想将文件直接上传到文件夹中。我得到了文件夹 ID,并且我有这段代码可以完美地在根目录中上传文件:
<?php
require_once 'get_access.php';
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
$folder_id = '<folder id>';
$client = new Google_Client();
$client->setClientId('<client_id>');
$client->setClientSecret('<client_secret>');
$client->setRedirectUri('<url>');
$client->setScopes(array('<scope>'));
$client->setAccessToken($access);
$client->setAccessType('offline');
$client->refreshToken($refreshToken);
$service = new Google_DriveService($client);
//Insert a file
$file = new Google_DriveFile();
$file->setTitle('My document 123');
$file->setDescription('A test document');
$file->setMimeType('text/plain');
$data = file_get_contents('document-2.txt');
$createdFile = $service->files->insert($file, array(
'data' => $data,
'mimeType' => 'text/plain',
));
echo '<pre>';
var_dump($createdFile);
echo '</pre>';
?>
为了将此文件上传到用户驱动器上的特定文件夹中,我应该在这里做什么?
谢谢