파일 업로드를 위해 Google 드라이브 API를 사용하고 있습니다. 이것은 내 코드 에 지금까지 내 코드이며 지금 다른 폴더로 경로를 변경하고 싶습니다.PHP를 사용하여 Google 드라이브 API를 사용하여 특정 폴더에 파일 업로드
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
$client = new Google_Client();
// Get your credentials from the APIs Console
$client->setClientId('***');
$client->setClientSecret('***');
$client->setRedirectUri('http://***');
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
if(empty($_GET['code']))
{
$client->authenticate();
}
$myfile= "video.mp4";
$type='video/mp4';
$service = new Google_DriveService($client);
// Exchange authorization code for access token
$accessToken = $client->authenticate($_GET['code']);
$client->setAccessToken($accessToken);
//Insert a file
$file = new Google_DriveFile();
$file->setTitle('filename.mp4');
$file->setDescription('A video');
$file->setMimeType($type);
$data = file_get_contents($myfile);
$createdFile = $service->files->insert($file, array(
'data' => $data,
'mimeType' => $type,
));
print_r($createdFile);
echo "<br />";
I에 유래 에서 몇 게시물을 시도하고 그들 중 누구도 내가 일을해야 부모 ID의 목록을 설정, 사전
새 클래스는 'Google_Service_Drive_ParentReference'라고합니다. – Moak