Is there a way to change where Elgg files save to?

Safe to say, ive been looking around and it appears all data saves to a folder which isnt very easily accessed at the moment. So, I was hoping to save to a part of the folder where the plugin is located, take this for example.


//save to file
$file = new ElggFile();
$file->owner_guid = 7777;



Currently it seems to save into some far off locked folder which can only be accessed via Command prompt, while I would prefer it saves to `Mod/Automated_View_Script/reports/` to make it much easier for us.

Is there a simple way to do this? 

  • Elgg files are access controlled and should not live in a publically accessible directory. All plugin files are publically accessible, so unless that's what you want, you need to reconsider your approach.

    The far off locked directory is what you specified during installation.

    What exactly are you trying to do?

  • Essentially im trying to save a text file filled with info from placeholder text and variables on a Form page. Clearly I cannot do that with Elgg as it saves to the database folder which is inaccessible for what this plugin will be used for.


    I have moved towards regular PHP but regular PHP doesnt seem to want to save the file correctly after I press the save button. Does |Elgg not play nice with regular php functions?


    code example

    //Get the page
    $title = get_input('title');
    $body = get_input('body');
    $date = date("l jS F Y h:i A");


    //print to file


    $folderName = 'Report';
    $FileName = '././Reports/' . $folderName . " " . $date . '.txt';
    $ReportContent = $body;


    if (file_put_contents($FileName, $ReportContent)) {
    system_message("Report Created (" . basename($FileName) . ")");
    } else {
    register_error("Report (" . basename($FileName) . ") was not saved!");


    Let me know if you can! 

  • You can save files in a regular Elgg action, just don't use ElggFile

  • How would I go about doing that then? Im sort of ripping my hair out here trying to figure out why I am having so much trouble saving this data to a text file.


    In case you need to know, my information is brought it from a form that this save action is listed from, $body contains the information that I would like printed out in the text file.

    If possible I want the file to save to /pluginfolder/Reports, or at least the /pluginfolder/actions where the save page im using is located.

  • I am not going to give you a solution, because I don't want to encourage insecure practices.

  • Example of bad practice in mod/gifts/actions/savegifts.php of the Gifts plugin (

  • Well alright then.

    Is at least possible to save in the directory specified as a text file with elggFile, rather than a database entry which it should technically do? Or is that also bad practice?

    Or at least some way that the user will be able to open and read that saved file?


    For the record, I am once more using the Elgg file system but even though the save is said to be successful, I cannot find it while browsing the storage location in the dataroot.

  • $file = new ElggFile();
    $file->owner_guid = 5001;
    // if you want a database record

    You can now find your file in:

    $dataroot is whatever is you specified as the document/upload path (you can see it your advanced site settings)
    $bucket is a bucket to which entity guid belongs. Buckets are incremented with 5000, so entity storage directory for entity with 5001 will be in /5000/5001, for 10999 in /10000/10999.
    $guid is the guid of the entity that owns files
    $filename is a path to the file
    So, if your dataroot is /var/www/html/data/, you will find the above file in:

    Now if you need to open/download the file, you just use the same owner guid and filename.

    $file = new ElggFile();
    $file->owner_guid = 5001;
    if ($file->exists()) {
       // file exists on the file store
       $download_url = elgg_get_download_url($file);
    // or
    if ($file->exists()) {
       $bytes = $file->grabFile();
       echo $bytes;
  • This should help a lot, it might be some time before I can implement it due to other things im currently working on, but thank you for assisting me with this! I'll get to it as soon as I can.