Я хотел бы принудительно загрузить файлы с Google Drive на ПК-клиент с помощью этого сценария:
<?php
//Get info about the file from a previous page (its name, type e.g. "rar", and file id which is the $download)
$download = $_GET['download'];
$name = $_GET['name'];
$type = $_GET['type'];
//Get json info about the file on drive, used to get its size in bytes
$json = file_get_contents('https://www.googleapis.com/drive/v2/files/'.$download.'?key=MYAPIKEY');
$obj = json_decode($json);
$size=$obj->fileSize;
//Download the file
$file = 'https://www.googleapis.com/drive/v3/files/'.$download.'?key=MYAPIKEY&alt=media';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$name.'.'.$type.'"');
header('Content-Length: '.$size);
readfile($file);
exit;?>
Файл поврежден при загрузке, любая помощь?[РЕДАКТИРОВАТЬ] Я получил его на работу, если кто-то еще хотел бы знать, как это сделать: добавьте header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
в начале строки заголовка.