zendframework/zf2 — pull request #2439 by cgmartin (2012-09-28 05:27:38+00:00)
Title: [2.1][WIP] File Uploads refactor

This PR refactors File Uploads to use Zend\Form's normal input filtering rather then using Zend\File\Transfer.

**Work-in-progress: Putting it out for review before I went too far in this direction, in case I'm way off-base.** The PR contains the essential mods for File Uploads to work, but stops short in a few areas (ie. File Validators, Unit Tests).

Notes:
* Zend\File\Transfer HTTP adapter is not used.
* Filters and Validators are added to File's input filter, just like any other form input.
* New Zend\InputFilter\FileInput will do validation on the file first, then filtering.
* InputFilter has been modified to detect if File Upload is missing, for isRequired/isEmpty tests.
* Tested with Zend\Form\Element\Collection for multi-file uploads.

One thing that might be problematic for some... You must be cognizant to pass the $_FILES info into the Form:
```php
$data = array_merge(
$this->getRequest()->getPost()->toArray(),
$this->getRequest()->getFiles()->toArray()
);
$form->setData($data);
```

Full usage example here:
https://gist.github.com/3797983

If Zend\File\Transfer has purpose that I'm overlooking, let me know and we can scrap this PR. It looked like Zend\File\Transfer was meant to provide upload and download support with different adapters (ftp, webdav) but not much traction in ZF1? It seemed a little over-engineered IMO. It will be a breaking change to remove it, obviously, for those currently using it in ZF2 (they could fall back to ZF1 if necessary?).

TODO:
* Fix File Validators to accept either $_FILES array info or a string filename, and remove Zend\File\Transfer support.
* Add a new File Filter for moving uploaded files or add support to Zend\Filter\File\Rename (security).
* Move Zend\File\Transfer\Adapter\Http methods for upload progress somewhere else (maybe under Zend\ProgressBar?).
* Remove Zend\File\Transfer and tests(?)
* Fix Unit Tests.