Tôi đang sử dụng api ổ đĩa google để tải lên tệp, Đây là mã của tôi cho đến nay bây giờ tệp tải lên thư mục gốc của tôi và tôi muốn thay đổi đường dẫn đến thư mục khác,Tải tệp lên thư mục cụ thể bằng cách sử dụng api google drive bằng PHP
<?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 />";
tôi đã cố gắng vài bài viết từ stackoverflow và không ai trong số họ làm việc cho tôi, tôi đã nhận lỗi, Cảm ơn trước
Lớp mới được gọi là 'Google_Service_Drive_ParentReference' – Moak