phpSPO
phpSPO copied to clipboard
Issue while moving Files
I have been trying to move a set of files for the root folder of path : "/sites/myfolder/Shared Documents/samplefolder/myfolder/2020/08/5000256-test1' .I am getting error like this as below
Fatal error: Uncaught Exception: The expression "Web/getfilebyserverrelativeurl('/sites/myfolder/Shared Documents/samplefolder/myfolder/2020/08/5000256-test1')/moveto(newurl=''/sites/dm-btl/Shared" is not valid.
$ctx->getWeb()->getFileByServerRelativeUrl($sourcePath)->moveTo("'{$targetPath}'",1);
please guide me to resolve this issue. May be because of the space between 'Shared Document' is what I primarly suspect.
Try: $ctx->getWeb()->getFileByServerRelativeUrl($sourcePath)->moveTo("{$targetPath}",1); (without sigle quotes) or simply: $ctx->getWeb()->getFileByServerRelativeUrl($sourcePath)->moveTo($targetPath,1);