Search code examples
typo3extbasetypo3-6.2.xfal

TYPO3 Extbase extension: Backend FAL Upload fails


I have set up an extension with the current extension_builder in TYPO3 6.2.11. FAL File upload in the backend is not working.

extension_builder says that file upload isn't implemented at all in extbase, but as far as I understood (cf https://github.com/helhum/upload_example), this is regarding FE upload. Correct?

I only need completely regular BE file upload - select via "Create new relation" or "Select & upload files".

The direct upload fails with "Upload failed! A file with "*" extension is expected!" (or whatever extensions I specify in TCA).

The reference creation works, but the reference is lost after saving.

This screenshot shows the two tries before saving.

enter image description here

And after saving, empty again:

enter image description here

How do I make this work? Do I have to add extra code to the repo for saving the relation? Or might there be a basic setting missing?

For tt_content, FAL relations and upload work fine.

And: As a workaround, is it possible to use a regular "Pibase" 'type' => 'group','internal_type' => 'file' field? But how would getters and setters in the model look then? Just like a regular string?

TCA:

    'apprenticeship_document' => array(
      'exclude' => 1,
      'label' => 'LLL:EXT:stellen/Resources/Private/Language/locallang_db.xlf:tx_stellen_domain_model_institution.apprenticeship_document',
      'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
        'apprenticeshipDocument',
        array('maxitems' => 1),
        '*'
      ),
    ),

Model as created by extension_builder:

/**
 * apprenticeshipDocument
 *
 * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
 */
protected $apprenticeshipDocument = NULL;

/**
 * Returns the apprenticeshipDocument
 *
 * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $apprenticeshipDocument
 */
public function getApprenticeshipDocument() {
    return $this->apprenticeshipDocument;
}

/**
 * Sets the apprenticeshipDocument
 *
 * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $apprenticeshipDocument
 * @return void
 */

public function setApprenticeshipDocument(\TYPO3\CMS\Extbase\Domain\Model\FileReference $apprenticeshipDocument) {
    $this->apprenticeshipDocument = $apprenticeshipDocument;
}

I have also tried to use \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> instead of \TYPO3\CMS\Extbase\Domain\Model\FileReference $apprenticeshipDocument, but that doesn't make a difference either.


Solution

  • Your TCA definition has an error, the first argument of getFileFieldTCAConfig should be with lower underscore, not lowerCamelCase:

    'apprenticeship_document' => array(
      'exclude' => 1,
      'label' => 'LLL:EXT:stellen/Resources/Private/Language/locallang_db.xlf:tx_stellen_domain_model_institution.apprenticeship_document',
      'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
        'apprenticeship_document',
        array('maxitems' => 1),
        'pdf,doc,docx'
      ),
    ),
    

    Apart from that, "*" is not a valid file extension. You need to define a comma-separated list of file extensions (e.g. 'doc,docx,pdf'). From reading the documentation, there is no wildcard for file extensions.

    File upload in FE is not implemented in the Extension Builder, but perfectly possible with the solution provided by Helmut Hummel.