Cómo guardar el nombre del archivo cargado en la base de datos
Cont. -Agregar File Uploader a Joomla Admin Component
Pude subir el archivo y guardarlo en el disco. Pero no es guardar el nombre del archivo en la base de datos.
Cómo puedo hacerlo ?
Aquí está el controlador -
class InvoiceManagerControllerInvoiceManager extends JControllerForm
{
function save(){
$file = JRequest::getVar('jform', null, 'files', 'array');
$path = JPATH_BASE;
// Make the file name safe.
jimport('joomla.filesystem.file');
$file['name']['invoice'] = JFile::makeSafe($file['name']['invoice']);
// Move the uploaded file into a permanent location.
if (isset($file['name']['invoice'])) {
// Make sure that the full file path is safe.
$filepath = JPath::clean($path. DS ."components". DS ."com_invoicemanager". DS ."files". DS .strtolower($file['name']['invoice']));
// Move the uploaded file.
JFile::upload( $file['tmp_name']['invoice'], $filepath );
}
return parent::save();
}
}
Campo de formulario en XML -
<field name="invoice" type="file"/>
ACTUALIZACIÓN: se trabajó después de agregar las siguientes líneas tomadas del código de @Andras Gera
$data = JRequest::getVar( 'jform', null, 'post', 'array' );
$data['invoice'] = strtolower( $file['name']['invoice'] );
JRequest::setVar('jform', $data );