[TYPO3-dev] FAL: Remove files in frontend extension

Klaus Heuer post at heuer-illustration.de
Tue Apr 22 11:44:00 CEST 2014


Hi list,

in my extbase extension I need a FRONTEND  image upload / delete 
function with FAL.

The upload function is working well, thanks to Frans for his bitbucket 
fal_fe_upload snippet.

But how to detach a file?

class my model
  /**
      * @var 
\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> 
$file
      *
      */
     protected $file;
...
     /**
      * Adds a file // this is working well
      *
      * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file
      *
      * @return void
      */
     public function 
addFile(\TYPO3\CMS\Extbase\Domain\Model\FileReference $file) {
         $this->files->attach($file);
     }

     /**
      * Removes a file // will not work
      *
      * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file
      * @return void
      */
     public function removeFile($file) {
     $this->files->detach($file);
}

Ends in Error: Call to undefined function detach() ....

I will not remove the file itself, only the entry in the file reference 
table...

There are some hints in the net, that I have to build my own database 
query here, but I can't belive, that an attach is working - and for a 
detach I have to build the complete query by my own.

Have someone done similar and can give me a hint?

System: TYPO3 6.2.1

Thanks, Klaus





More information about the TYPO3-dev mailing list