I have been looking into file uploading in ZF2.
I understand that many of you will think that this is too vague a question, but what is the best way to create form elements which have a bit more processing?
I can't seem to work out where to start. I have ruled out processing it in the controller as this will break DRY principles. The form object doesn't seem to have a place to 'hook' any code into. The view helper is just that, for the view so it doesn't make sense to do anything in that. So that leaves the input filter. That doesn't seem right either.
I have been steered towards transfer adapters but the code looks like it's not very ZF2.
I'm sorry that this is such a vague question and I'm hoping it falls on sympathetic ears. It's hard learning a framework that has very little documentation and compounded with the fact that my zend framework 1 knowledge is a little thin it, progress is a little slow.
Once I have a good example working I will perhaps find some place to post it.
to retrieve the $_FILES, you do the following in the controller:
This post is old but i hope this helps someone.
it's simple:
[In Your Controller]
UPDATE : I found better way to use file validation with form validation :
Add this class to your module e.g : Application/Validators/File/Image.php
Use in form and add filterInput :
And in your controller :
File upload factory and validation is scheduled to ZF2.1
Mean while I use $_FILES :(
Check the following links:
From what i asked / seen in irc (#Zftalk.2) the file component is yet to be refactored
This is a old question, but in case someone else get here, I found this good article:
Create Simple Upload Form with File Validation
This is a good start to work with files in ZF2. ;)