1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

How to rename a fileupload archive assign a id user number

Discussion in 'Community' started by javier94, Sep 13, 2018 at 4:46 PM.

  1. javier94

    javier94 Member

    Level: Community

    is possible in a fileupload element.. assign a id user number before the name used by the user..

    imagine than a user upload a file.. i would like that when the user save this fileupload.. the name of the archive will be.... userid number + "name called by the user" for this file..

    Is possible?? or make something similar??

    thanks in advance

  2. achartier

    achartier Active Member

    Level: Community
    You have 2 options. First you can insert php code in the fileupload element Rename Code area that will return the new name of the file, or second you can add a onAfterprocess form plugin to do the same but you will need to change the filename on the server with a JFile type call. The first option is probably easier unless you want to move the file after it has been uploaded.
  3. troester

    troester Administrator Staff Member

    Level: Community
    If it's not essential to have the userid directly in the filename you can define the upload folder to include the userid with a placeholder {$my->id}
    achartier likes this.
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    As @achartier said, the easiest way to change the filename itself is the rename feature in the upload element settings.

    Something like ...

    Code (Text):

    return $this->user->get->('id') . $filename;
    -- hugh

Share This Page