How to rename a fileupload archive assign a id user number

javier94

Member
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
 
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.
 
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}
 
As @achartier said, the easiest way to change the filename itself is the rename feature in the upload element settings.

Something like ...

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

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top