Im getting an error when im trying to rename a file when uploading.
I use the following code:
Any suggestions?
I use the following code:
PHP:
import( 'joomla.filesystem.file' );
// Get values from input fields
$dier_id = $formModel->formData['dier_id'];
$naam_dier = $formModel->formData['naam_dier'];
$achternaam = $formModel->formData['achternaam'];
// Split the original filename and get the file extension
$old = ($formModel->formData['foto_huisdier']);
$oldParts = pathinfo($old); $extensie = $oldParts['extension'];
// Combine the input field values to create the new filename
$nieuw_bestand = $naam_dier . '' . $achternaam . '' . $dier_id . '.' . $extensie;
// Move the original file to the new location and give it a new name
JFile::move(JPATH_SITE.$old, JPATH_SITE.$nieuw_bestand);
// Update the form data and the database with the new filename
$formModel->updateFormData('foto_huisdier', $nieuw_bestand, true);
$object = new stdClass();
$object->id = $formModel->formData['dier_id'];
$object->bestandsnaam = $nieuw_bestand;
$result = JFactory::getDbo()->updateObject('klant_diergegevens', $object, 'dier_id');
Any suggestions?
Last edited: