Forums

Update image file name

nbento 23 Apr, 2015
I have a form that load the data and then updates. It works fine.

I want to change the name of the image that is saved in DB.
After submit the form i have:
Array
(
    [image] => Array
        (
            [name] => 20150423151457_iva.jpg
            [original_name] => iva.jpg
            [path] => /var/www/html/images/contactos/20150423151457_iva.jpg
            [size] => 3618
            [link] => http://www.eseig.ipp.pt/images/contactos/20150423151457_iva.jpg
        )
)


The name that is saved in DB is "20150423151457_iva.jpg" but what i want is "images/contactos/20150423151457_iva.jpg"

How can i do this?
GreyHead 24 Apr, 2015
Answer
1 Likes
Hi nbento,

Use a Custom Code action after the Upload files action to create the variable you want
<?php
$temp = $form->files['image']['path'];
$temp = str_replace(JPATH_SITE, '', $temp);
$form->data['image_v2'] = $temp;
?>

Bob
nbento 24 Apr, 2015
Once again, thanks!!!
Perfect!!!
This topic is locked and no more replies can be posted.