rename fileuploads in repeat group

kouwearie

Member
How to rename fileuploads in a repeat group? The database is not the main joomla DB.
When using the example it gets an error, "mainDBname.ep_submission" doesnt exist.
How can i target elements from the repeated group to use for the rename?

Maybe good to mention its not repeated data but database join based.

// use Joomla file utils
jimport( 'joomla.filesystem.file' );
// get the original file and split it into parts
$old = ($formModel->formData['file']);
$oldParts = pathinfo($old);
// in this example we're using the id as the new filename
$sid = $formModel->formData['id'];
//create the new file (path and name)
$new = $oldParts['dirname'].'/'.$sid.'.'.$oldParts['extension'];
// update the file itself
JFile::move(JPATH_SITE.$old, JPATH_SITE.$new);
// update the data
$formModel->updateFormData('file', $new, true);
// update the db
$object = new stdClass();
// Must be a valid primary key value.
$object->id = $sid;
// new path + name
$object->file = $new;
// Update the data in the db
$result = JFactory::getDbo()->updateObject('ep_submission', $object, 'id');
 

Members online

No members online now.
Back
Top