Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if file/folder exists, when entity name contains "#"? #327

Open
F4T4LERROR opened this issue Mar 21, 2023 · 0 comments
Open

Check if file/folder exists, when entity name contains "#"? #327

F4T4LERROR opened this issue Mar 21, 2023 · 0 comments
Labels

Comments

@F4T4LERROR
Copy link

F4T4LERROR commented Mar 21, 2023

Hello,

The developer, @vgrem has already provided comments on how to check if a folder exists in issue 241.

However, this doesn't appear to work if the SharePoint file/folder name contains a "#" symbol. I tried using rawurlencode on the folder name and path, but no joy. I can create/edit/delete files/folders that contains the "#" symbol. I can create entities inside of those folders in SharePoint using PHPSPO. But I can't check if they exist. Am I doing something wrong? Is this not possible?

$checkFolder = "/sites/company/jobs/Job-ABC123 #2";
$folder = $ctx->getWeb()->getFolderByServerRelativeUrl($checkFolder)->select(["Exists"])->get()->executeQuery();
if(!$folder->getExists()){
    print_r("Folder {$checkFolder} has not been found");
} else {
    print_r("Folder {$checkFolder} has been found");
}

Note, it also doesn't work if I use
$checkFolder = rawurlencode("/sites/company/jobs/Job-ABC123 #2");

Or if I use:
$folder = $ctx->getWeb()->getFolderByServerRelativeUrl(rawurlencode($checkFolder))->select(["Exists"])->get()->executeQuery();

Any guidance or clarification appreciated.

@vgrem vgrem added the bug label Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants