01.
02.
$client
= getClient();
03.
$service
=
new
Google_Service_Drive(
$client
);
04.
05.
06.
$fileMetadata
=
new
Google_Service_Drive_DriveFile(
array
(
07.
'name'
=>
'IMGUpload'
,
08.
'mimeType'
=>
'application/vnd.google-apps.folder'
));
09.
$file
=
$service
->files->create(
$fileMetadata
,
array
(
10.
'fields'
=>
'id'
));
11.
printf(
"Folder ID: %s\n"
,
$file
->id);
12.
13.
14.
$file
=
$_FILES
;
15.
16.
$fileMetadata
=
new
Google_Service_Drive_DriveFile(
array
(
17.
'name'
=>
$file
[
"fileUpload"
][
"name"
],
18.
'parents'
=>
array
(
'1P4vY97UnmJMw14Y3KIm-UV_uyr41ywrO'
)
19.
));
20.
$content
=
file_get_contents
(
$file
[
"fileUpload"
][
"tmp_name"
]);
21.
$file
=
$service
->files->create(
$fileMetadata
,
array
(
22.
'data'
=>
$content
,
23.
'mimeType'
=>
$file
[
"fileUpload"
][
"type"
],
24.
'uploadType'
=>
'multipart'
,
25.
'fields'
=>
'id'
));