So speichern Sie den Namen der hochgeladenen Datei in der Datenbank

Fortsetzung -Fügen Sie File Uploader zur Joomla Admin Component hinzu

Ich konnte die Datei hochladen und auf der Festplatte speichern. Der Dateiname wird jedoch nicht in der Datenbank gespeichert.

Wie kann ich es tun ?

Hier ist der Controller -

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();
    }
}

Formularfeld in XML -

<field name="invoice" type="file"/>

UPDATE: Funktioniert nach dem Hinzufügen der folgenden Zeilen aus @Andras Gera-Code

$data = JRequest::getVar( 'jform', null, 'post', 'array' );
$data['invoice'] = strtolower( $file['name']['invoice'] );

JRequest::setVar('jform', $data );

Antworten auf die Frage(5)

Ihre Antwort auf die Frage