phpSPO
phpSPO copied to clipboard
Add an attachment to a list item with custom AuthorId/EditorId field
I removed AuthorId and EditorId as readonly fields.
I'm using phpSPO to create list item as another user (know the ID). How can I send those fields when adding attachment?
$list = $this->client->getWeb()->getLists()->getByTitle("listTitle");
$ctx = $list->getContext();
$listItem = $list->addItem([
"Title" => "title",
'Comment' => "comment",
"AuthorId" => "id",
"EditorId" => "id",
]);
$ctx->executeQuery();
$attCreationInformation = new AttachmentCreationInformation();
$attCreationInformation->FileName = basename("filename");
$attCreationInformation->ContentStream = file_get_contents("filepath");
$listItem->getAttachmentFiles()->add($attCreationInformation);
$ctx->executeQuery();