Thanks for your reply.
Unfortunately, nothing helped.
I tried to do this:
$file = new \ElggFile();
$file->owner_guid = $user->guid;
$filename = elgg_strtolower('file/' . time() . 'file.jpg');
$file->setFilename($filename);
$file->filestore_prefix = 'file';
$file->open('write');
$file->write($content);
$file->close();
There was a typo in the previous example not $user->owner_guid but $user->guid.
But that didn't help either.
I'm using Elgg 5.1.9
As Jerome said, setting
$file->owner_guid = $user->guid;
is the reason.
Have you tried NOT setting owner_guid at all?
It also seems you're not setting container_guid in the code of your latest post. I guess you could still set
$file->container_guid = $user->guid;
to preserve the owner information after omitting to set owner_guid.
Thanks, iionly.
I tried doing this with different variations of the code.
For example, this one:
$file = new \ElggFile();
$filename = time() . 'file.txt';
$file->setFilename($filename);
$file->filestore_prefix = 'file';
$file->open('write');
$file->write('Test');
$file->close();
But the file is still saved in the logged in user's folder, but not under its own GUID
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.