phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

how to get all files of folder that contains more folders and files?

Open Victor-capilla opened this issue 3 years ago • 2 comments

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')); }

Victor-capilla avatar Nov 03 '20 11:11 Victor-capilla

Hello, Do you have any solution ?

WENKz avatar Feb 25 '21 17:02 WENKz

Hello do you have a solution for this.

traderit avatar Nov 22 '23 19:11 traderit