F.schettino
Italian
I need rename file uploaded using File upload element.
I need modify only the name (as "surname_name_id"), not the path and not the extension.
I red
but I don't understand what I have to personalize in it.
'joomla.filesystem.file' 'file' 'ep_submission' are fixed or have I to personalize? How? I mean: what is their meaning?
How define the new filename as "surname_name_id" (same path and extension)? And how read filename, "surname", "name", "id" in the submitted form?
Have I to personalize something else?
I need modify only the name (as "surname_name_id"), not the path and not the extension.
I red
PHP:
// 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');
but I don't understand what I have to personalize in it.
'joomla.filesystem.file' 'file' 'ep_submission' are fixed or have I to personalize? How? I mean: what is their meaning?
How define the new filename as "surname_name_id" (same path and extension)? And how read filename, "surname", "name", "id" in the submitted form?
Have I to personalize something else?