[Flow] Filetype Validator
Søren Malling
soren.malling at gmail.com
Wed Jan 22 10:32:51 CET 2014
Try and add the following annotation to your "image" property in the model
@Flow\Validate(type="\TYPO3\Media\Validator\ImageTypeValidator", options={
"allowedTypes"={"jpeg", "png"} })
On Wed, Jan 22, 2014 at 9:07 AM, Jan Greth <jan at greth.me> wrote:
>
>> I don't have one, but what filetypes are you looking for? With
>> TYPO3.Media,
>> there is a ImageValidator as an example
>>
>>
> Yes that's exactly what I'm looking for. I want to upload Images with the
> TYPO3.Media Package. But till now I could not validate, that the uploaded
> file is really an image.
>
> For example when i upload a pdf i get an error "An error occurred while
> trying to call JPG\Media\Controller\ItemController->createAction()".
> Is that the (relly cryptic) error of the validator?
>
> the create Action is nothing special just:
> /**
> * @param \JPG\Media\Domain\Model\Item $newItem
> * @return void
> */
> public function createAction(Item $item) {
> $this->itemRepository->add($item);
> $this->addFlashMessage('Created a new item.');
> $this->redirect('index');
> }
>
>
> and inside my Model there is just:
> [...]
> /**
> * @var \TYPO3\Media\Domain\Model\Image
> * @ORM\OneToOne(cascade={"all"}, orphanRemoval=true)
> */
> protected $image;
> [...]
> /**
> * @param \TYPO3\Media\Domain\Model\Image $image
> * @return void
> */
> public function setImage($image) {
> $this->image = $image;
> }
>
> /**
> * @return \TYPO3\Media\Domain\Model\Image
> */
> public function getImage() {
> return $this->image;
> }
> [...]
>
>
> It's just my small lerning project, but i think this is an important task.
>
> Cheers,
>
> Jan
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>
More information about the Flow
mailing list