Buy Now
Sign in

Amend file name

ctrlmedia , May 05 2017, 15:38
C
ctrlmedia 168
May 05 2017, 15:38 #367798
Hi,
I am looking at trying to add some form data to a filename?
I cant see where this is done?

I have added some custom code after the upload function but I think this is too late. It changes the name but its not being saved to the the upload array so the physical filename is not changed.

If I do it before the upload the name doesn't seem to exist so there is nothing to change.

Heres the code:
<?php $this->data['file1'] = ($this->data['category'].'_'.$this->data['file1']); ?>


at the minute I the name is: timestamp_filename.jpg
I want someformdata_timestamp_filename.jpg

or can this be done in the "Files config" box in the upload?

Any help would be much appreciated.
Kind Regards
C
ctrlmedia 168
May 05 2017, 18:20 #367817
I can see that my code actually works (by putting debug before the upload function) but after the upload the bit I added is replaced by a timestamp. I would like my bit as well as the timestamp. Where does it actually add the timestamp?

Also, I was wondering why the filename includes the extension and then the extension is re-added? (filename-jpg.jpg)

Regards
admin 31
May 05 2017, 22:00 #367822
Hi Mark,

The easiest way for now is to rename the file after the upload action using PHP code, you can get the file path using this code:

$this->get("upload_action_name.file_field_name.path");

There is currently no other way to build or modify the file name.

Best regards,
Max