PHP code example of tes / laravel-google-drive-storage
1. Go to this page and download the library: Download tes/laravel-google-drive-storage library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tes / laravel-google-drive-storage example snippets
use Tes\LaravelGoogleDriveStorage\GoogleDriveService;
$file = $request->file('upload'); // Assuming this comes from a form
$response = GoogleDriveService::uploadFile($file);
echo "File uploaded with ID: " . $response->id;
use Tes\LaravelGoogleDriveStorage\GoogleDriveService;
$folderName = 'New Folder';
$response = GoogleDriveService::createFolder($folderName);
echo "Folder created with ID: " . $response['folderId'];
use Tes\LaravelGoogleDriveStorage\GoogleDriveService;
$searchName = 'example';
$files = GoogleDriveService::search($searchName, 'all'); // Can be 'files', 'folders', or 'all'
foreach ($files as $file) {
echo "Found file with ID: " . $file['id'] . " and name: " . $file['name'] . "\n";
}
use Tes\LaravelGoogleDriveStorage\GoogleDriveService;
$folderId = 'your_folder_id';
$files = GoogleDriveService::listFilesInFolder($folderId);
foreach ($files as $file) {
echo "File in folder with ID: " . $file['id'] . " and name: " . $file['name'] . "\n";
}