所有我需要的是删除一个文件,这是我的共享驱动器文件夹内使用谷歌/apiclient使用php,这是我的代码如下。
session_start();
require __DIR__ . '/vendor/autoload.php'; // ready the API to upload to drive
use Google\Client;
use Google\Service\Drive;
if (isset($_POST['file'])) {
$file = $_POST['file'];
$client = new Client();
putenv('GOOGLE_APPLICATION_CREDENTIALS=./credentials.json');
$client->useApplicationDefaultCredentials();
$client->addScope(Drive::DRIVE);
$driveService = new Drive($client);
$delete = $driveService->files->delete($file);
if ($delete) {
$_SESSION['success'] = "Video deleted successfully";
header("Location: upload");
}
}
1条答案
按热度按时间gojuced71#
如果您的客户端具有从共享驱动器删除文件的权限,那么下面的修改怎么样?
发件人:
收件人:
注:
参考: