【问题标题】:TYPO3 Extbase extension: Backend FAL Upload failsTYPO3 Extbase 扩展:后端 FAL 上传失败
【发布时间】:2015-03-31 08:22:54
【问题描述】:

我在 TYPO3 6.2.11 中使用当前的 extension_builder 设置了一个扩展。 后台 FAL 文件上传不工作。

extension_builder 说文件上传根本没有在 extbase 中实现,但据我了解(参见 https://github.com/helhum/upload_example),这是关于 FE 上传的。正确的?

我只需要完全常规的 BE 文件上传 - 通过“创建新关系”或“选择并上传文件”选择。

直接上传失败并显示“上传失败!需要一个带有“*”扩展名的文件!” (或我在 TCA 中指定的任何扩展名)。

引用创建工作,但保存后引用丢失。

此屏幕截图显示了保存前的两次尝试。

保存后,再次清空:

我该如何进行这项工作?我是否必须向 repo 添加额外的代码来保存关系?或者可能缺少基本设置?

对于 tt_content,FAL 关系和上传工作正常。

并且:作为一种解决方法,是否可以使用常规的“Pibase”'type' => 'group','internal_type' => 'file' 字段?但是模型中的 getter 和 setter 会是什么样子呢?和普通字符串一样吗?

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),
        '*'
      ),
    ),

由 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;
}

我也尝试使用\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> 代替\TYPO3\CMS\Extbase\Domain\Model\FileReference $apprenticeshipDocument,但这也没有什么不同。

【问题讨论】:

    标签: typo3 extbase typo3-6.2.x fal


    【解决方案1】:

    你的 TCA 定义有错误,getFileFieldTCAConfig 的第一个参数应该是小下划线,而不是小写形式:

    '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'
      ),
    ),
    

    除此之外,“*”不是有效的文件扩展名。您需要定义一个以逗号分隔的文件扩展名列表(例如'doc,docx,pdf')。通过阅读文档,文件扩展名没有通配符。

    在扩展生成器中没有实现 FE 中的文件上传,但使用 Helmut Hummel 提供的解决方案完全可以实现。

    【讨论】:

    • 我已经改变了它,但它没有帮助(卸载扩展,清除所有缓存等)。奇怪的。这只是关于 BE 上传
    • 也许是个愚蠢的问题,但为了安全起见:存在名为 apprenticeship_document 的字段吗?
    • 完全合理的问题。它存在。而你成功了!!!它适用于“pdf”(我试过.pdf)。谢谢!!!!我会将其发布在扩展构建器 forge 上。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-22
    相关资源
    最近更新 更多