First, im really new at typo3. I build a extension with extension builder, and now i want to upload images from the Frontend. The upload and the creating Folder function is working fine. But typo3 doesnt output the file after upload. According to several google searches i think it has to do with the file_reference function. But im really stuck on this. Hope somebody can heelp me on this.
Heres my creatAction Funnction:
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');
}