I want to manage files on nextCloud implementation (cd.wedos.com). I can connect to the server using winSCP and list, download & upload files. I want to do the same via PHP. Thanks to SO I am able to connect to webDAV server from my Windows 11 – my dev environment.
I did search on how to use Sabre webDAV client but no matter I do I have no idea how to list files.
$folder_content = $client->propfind('', []);
returns
array(5) {
["{DAV:}getlastmodified"]=>
string(29) "Thu, 18 Jul 2024 20:04:28 GMT"
["{DAV:}resourcetype"]=>
object(SabreDAVXmlPropertyResourceType)#14 (1) {
["value":protected]=>
array(1) {
[0]=>
string(16) "{DAV:}collection"
}
}
["{DAV:}quota-used-bytes"]=>
string(11) "11825361054"
["{DAV:}quota-available-bytes"]=>
string(13) "3286709522274"
["{DAV:}getetag"]=>
string(15) ""6699754ce26f9""
}
The official Sabre doc is using $client->propfind('collection', array(
but the parameter collection gives me error Not found, I used ” instead
$client->propfind('', array(
'{DAV:}displayname',
'{DAV:}getcontentlength',
));
That returns
array(1) {
["{DAV:}displayname"]=>
string(47) "wedos-auth-modified-0f5f-4c87-99a2-modified"
}
Which I have no idea what it means.
I found other examples how to use propfind
$folder_content = $client->propfind('', array(
'{DAV:}getlastmodified',
'{DAV:}getcontenttype',
));
That gives me result
array(1) {
["{DAV:}getlastmodified"]=>
string(29) "Thu, 18 Jul 2024 20:04:28 GMT"
}
In the official documentation there is section called “Discovering WebDAV features. I thought it would help. So I ran it
$features = $client->options();
which returns something that does not help me.
array(8) {
[0]=>
string(1) "1"
[1]=>
string(1) "3"
[2]=>
string(14) "extended-mkcol"
[3]=>
string(14) "access-control"
[4]=>
string(40) "calendarserver-principal-property-search"
[5]=>
string(25) "nextcloud-checksum-update"
[6]=>
string(18) "nc-calendar-search"
[7]=>
string(27) "nc-enable-birthday-calendar"
}
Is there someone who can help me to list all files and directories of a particular folder?