TYPO3 FAL上传前端添加标题,替代和描述

时间:2016-11-19 15:06:04

标签: upload typo3 extbase fal

我有一个扩展程序,用户可以在前端上传一些图像到他们的前端配置文件。图像上传和保存到用户配置文件工作正常,我用户遵循代码 - 但是有一个简单的方法来添加标题,替代和描述吗?

感谢您的帮助! 马丁

/** @var \TYPO3\CMS\Core\Resource\StorageRepository $storageRepository */
        $storageRepository = $this->objectManager->get('TYPO3\CMS\Core\Resource\StorageRepository');
        /** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storage */
        $storage = $storageRepository->findByUid('1');

        #$storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
        #$storage           = $storageRepository->findByUid(1); # Fileadmin = 1
        #$saveFolder        = $storage->getFolder($this->settings['uploadFolder']);

        $fileData = array();
        $fileData['name'] = $_FILES['tx_key_datenwartung']['name']['logo'][0];
        $fileData['type'] = $_FILES['tx_key_datenwartung']['type']['logo'][0];
        $fileData['tmp_name'] = $_FILES['tx_key_datenwartung']['tmp_name']['logo'][0];
        $fileData['size'] = $_FILES['tx_key_datenwartung']['size']['logo'][0];


        // this will already handle the moving of the file to the storage:
        $newFileObject = $storage->addFile(
                $fileData['tmp_name'], $saveFolder, $userUid.'_'.$fileData['name']
        );
        $newFileObject = $storage->getFile($newFileObject->getIdentifier());
        #$newFile = $this->fileRepository->findByUid($newFileObject->getProperty('uid'));

        $newFile = $newFileObject->getUid();

        $persistenceManager = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
        $persistenceManager->persistAll();

        /** @var \Vendor\Myextension\Domain\Model\FileReference $newFileReference */
        $newFileReference = $this->objectManager->get('Ven\Key\Domain\Model\FileReference');
        $newFileReference->setFile($newFile);


        $user->addLogo($newFileReference);

1 个答案:

答案 0 :(得分:0)

....可以自己解决。只需将setter添加到模型并添加文本:

/**
 * Set alternative
 *
 * @param \xx\yy\Domain\Model\File $file
 */
public function setAlternative($alternative) {
    $this->alternative = $alternative;
}
和控制器:

$ newFileReference-> setAlternative('您的图片替代文字');