首先,我对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');
}