1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

How to rename a fileupload archive assign a id user number

Discussion in 'Community' started by javier94, Sep 13, 2018.

  1. javier94

    javier94 Member

    Level: Community
    hello..

    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

    Javier94
     
  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 Well-Known Member 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