phpSPO
phpSPO copied to clipboard
how to get all files of folder that contains more folders and files?
i would like how to get all files of one folder that contains more folders and files.
This is my code :
$ctx = ClientContext::connectWithUserCredentials($sharepoint['url'], $sharepoint['user'], $sharepoint['password']);
$folders = $ctx->getWeb()->getFolders(); $ctx->load($folders); $ctx->executeQuery(); $files = []; foreach ($sourceList->getData() as $folder) { error_log("folder : ". $folder->__get('Name')); $subFolders = $folder->getFolders(); $ctx->load($subFolders); $ctx->executeQuery(); $contentsOfSubsFolders =$subFolders->getData(); foreach ($contentsOfSubsFolders as $folderOfSubFolderContent ) { error_log("subfolder : ". $folderOfSubFolderContent->__get('Name')); // i would like get all files here , but i need iterare in loop $files = $folderOfSubFolderContent->getFiles(); $ctx->load($files); $ctx->executeQuery(); error_log("file extracted of folder : ". $car->__get('Name')); }
Hello, Do you have any solution ?
Hello do you have a solution for this.