Skip to content

Get File Properties #347

@wayzz1992

Description

@wayzz1992

Hi

I am new to using phpSPO and am trying to get the list of properties of my files. I have followed the examples and some threads and this is the code I am using :

        $files = $this->ctx->getWeb()->getFolderByServerRelativeUrl($listTitle)->getFiles()->expand("ListItemAllFields");
        $this->ctx->load($files);
        $this->ctx->executeQuery();
        
        foreach ($files->getData() as $file) {
            $properties = $file->getListItemAllFields();
            error_log(json_encode($properties));

            error_log("name: '{$file->getProperty("Title")}'") ;
            error_log("name: '{$file->getProperty("ServerRelativeUrl")}'") ;
        }

The code returns a list of files and I can access some of the properties but I also want to get the Author and some custom columns.

When using $properties->{$propname} code returns an empty string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions