File Upload Custom Folder / File Name

I am attempting to make a custom folder and file name for a file upload.

I would like to accomplish this type of file name.

'EMPLOYEE ACTIVE/'.$last_int.'/'.$last_name.' '.$first_name.'/{thistable___state} {thistable___certification_type} {thistable___expiration}' ;

The code I have tried in the rename file name is below.. However my understanding that is for the file name and not the location of the file.

$last_name= '{employees___last_name}';
$first_name= '{employees___first_name}';
$last_int = $last_name[0];
$last_int = strtoupper($last_int);
$last_name= strtoupper($last_name);
$first_name= strtoupper($first_name);
$path= 'EMPLOYEE ACTIVE/'.$last_int.'/'.$last_name.' '.$first_name.'/{thistable___state} {thistable___certification_type} {thistable___expiration}' ;
// 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');​
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top