I want to fix a bad design decision made in the Gifts plugin where uploaded gift images are saved in the gifts plugin dir. If possible I would like to make use of Elgg API functions to handle the upload, resizing and saving. Recently I've reworked the Badges plugin code and switched to Elgg 2.3 functions to handle this, e.g. acceptUploadedFile(), but the files will end in the user's subdirectory and you can only change the saving location relative to that with the filestore_prefix.
Is there any API function I can use instead to save the images in a subfolder directly in dataroot (or if not a ready-to-use function some code example in core I could take as starting point to see how to do it)?
Or is it better to save the uploaded files in the user's subdirectory anyway? The use case in the Gift plugin is that an admin uploads the gift images which are then used by other users on sending gifts. I guess with the access level set to public it would also work with the images in the user subdiretory (they are just not as easy to find then if you ever need to work directly with the files).
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.
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- Jerome Bakker@jeabakker
Jerome Bakker - 0 likes
- iionly@iionly
iionly - 0 likes
You must log in to post replies.Have the site entity own the gift files.
If you save the uploaded image with the Gift, it's saved in the Gifts directory, so something like
$gift = new Gift(); $gift->saveIconFromUploadedFile('admin_upload');
Or if it's not the icon of the Gift, but just a file
Thanks for the hint with site entity as owner. I will try that. This also helps keeping the files in case the admin account used for upload needs to be deleted for whatever reason.