2

首先,我对typo3 真的很陌生。我用扩展构建器构建了一个扩展,现在我想从前端上传图像。上传和创建文件夹功能工作正常。但是typo3在上传后不输出文件。根据几个谷歌搜索,我认为它与 file_reference 函数有关。但我真的坚持这一点。希望有人能帮我解决这个问题。

这是我的 creatAction 函数:

 public function createAction(\Demian\Inserateextension\Domain\Model\myObject $newObject)
    {


    $chiffre = $_POST['tx_myplugin']['myObject']['chiffre'];
    $newImagePath = 'inserate/'.$chiffre;


    if ($_FILES['tx_myplugin']['name']['gallerie'][0]) {


        $tmpName = $_FILES['tx_myplugin']['name']['gallerie'][0];
        $tmpFile  = $_FILES['tx_myplugin']['tmp_name']['gallerie'][0];

        $storageRepository = $this->objectManager->get('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
        $storage = $storageRepository->findByUid('1'); //this is the fileadmin storage

        //build the new storage folder
        $targetFolder = $storage->createFolder($newImagePath);

     //Upload the file
        $movedNewFile = $storage->addFile($tmpFile, $targetFolder, $tmpName);



}

    $this->myObjectRepository->add($newObject);
    $this->redirect('list');
}
4

2 回答 2

0

也许你应该看看这个存储库。这是一个很好的例子,如何在 TYPO3 中使用 FAL 处理文件上传。也许有点旧,但机制应该变得清晰。 https://github.com/helhum/upload_example

于 2019-07-27T20:52:38.193 回答
0
于 2019-07-27T23:45:15.700 回答