Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google API 2.0 PHP服务器到服务器无法将文件上载到Google驱动器_Php_Drive - Fatal编程技术网

Google API 2.0 PHP服务器到服务器无法将文件上载到Google驱动器

Google API 2.0 PHP服务器到服务器无法将文件上载到Google驱动器,php,drive,Php,Drive,我正在尝试使用谷歌API 2.0(PHP版本)将图像从我的网站上传到我的谷歌硬盘。当我尝试下面的代码时,网页上没有报告错误,但我的照片没有上传。有人能帮我解决这个问题吗?我知道这件事。 require_once realpath('vendor/autoload.php'); $client = new Google_Client(); $client->setAuthConfig('vendor/MyProject.json'); $client->useApplicationD

我正在尝试使用谷歌API 2.0(PHP版本)将图像从我的网站上传到我的谷歌硬盘。当我尝试下面的代码时,网页上没有报告错误,但我的照片没有上传。有人能帮我解决这个问题吗?我知道这件事。
require_once realpath('vendor/autoload.php');

$client = new Google_Client();
$client->setAuthConfig('vendor/MyProject.json');
$client->useApplicationDefaultCredentials();
$client->addScope("https://www.googleapis.com/auth/drive");

$service = new Google_Service_Drive($client);
// This is uploading a file directly, with no metadata associated.
$file = new Google_Service_Drive_DriveFile();
$result = $service->files->create(
    $file,
    array(
        'data' => file_get_contents('1.jpeg'),
        'mimeType' => 'application/octet-stream',
        'uploadType' => 'media'
    )
);
?>