Zend Framework: No File Upload
June 8, 2008 Posted by Al Castle
trackback
Categories: Puter Stuff, Web Design & Dev, gnash-teeth
Tags: forms, frameworks, php, zend
My latest realization is that even though Zend Framework is version 1.5, it has absolutely no support in Zend_Form for file uploads.
Again, this seems to be a very common requirement for a web application which is not included. This limitation does not appear to be mentioned in the documentation either. I ended up searching through some forums to discover that it’s not implemented yet.
WTF?
Version 1.5 - Framework. Yeah.
Update:
Wil Sinclair of the Zend Framework responded in the comments about the necessity and difficulty of balancing what to include within the framework and the ability to keep it flexible. While I can appreciate this, I have to wonder why include input type password, or what about textarea instead of input type file. Why even create Zend_Form then?
To be clear I am not suggesting that a class be built to support file uploading, processing, saving, renaming and such. Simply that I am surprised that Zend_From does not appear to have support for input type=’file’ in the version 1.0-1.5 release. A web development framework should include the basics at least - Password, Text, Checkbox, Radio, File, Textarea, Submit.
Zend Framework includes plenty of classes for extraneous things like -
Zend_Service: Akismet, Amazon, Audioscrobbler, Delicious, Flickr, Nirvanix, Simpy, StrikeIron and Yahoo!
While I appreciate that these (and others) are included, and will no doubt make use of them as time goes on, surely those should all be secondary to some basics. To me, even (Zend_)PDF creation and (Zend_)Feed processing would be secondary to something as rudimentary as Zend_Form with the ability to select a file by version 1.0.
Not to say I’m not appreciative of the work that’s been done and the flexibility it provides me, I did after all choose it over the other frameworks I’ve mentioned in a previous post. It’s not as if I can’t write my own either, but simply that I find the absence of full disclosure in the documentation as well as the absence of this seemingly basic thing to make me say, WTF?
If I’ve missed it and it’s in a 14pt, bold font, blinking, marquee on the documentation page, then I humbly apologize. If it’s on a wiki or roadmap somewhere then I suggest you move it on over to the documentation pages where I’m looking at usage examples.
I’ll continue to post my grievances and no doubt eventually praise as I muddle through learning how to use this framework, so stay with me.

Comments»
There is a proposal currently in standard incubator: http://framework.zend.com/wiki/display/ZFPROP/Zend_File_Transfer+-+Thomas+Weidner. I *believe* there are plans to integrate this with Zend_Form. I’ll forward Matthew this post so he can give a bit more detail.
BTW, one reason why we don’t necessarily build out every feature that everyone expects in 1.0 frameworks is that we believe we can’t compromise extensibility and flexibility in making things simple. Of course, we believe that you don’t have to trade one off for the other, but we generally build toward simplicity. It’s a hard position to take, and it may not be the right philosophy/framework for you. We believe that in the long run this will serve our users best.
1.6 will be landing sometime this summer; if you’re still looking for this functionality you might want to keep an eye on it.
Best.
,Wil
Caveat: I’m the primary developer behind Zend_Form.
While _you_ may consider this a “very common requirement”, the fact of the matter is that the vast majority of forms do _not_ contain upload elements. I can count on one hand the number of requests for file uploads. On the other hand, the number of people requesting a form component in the first place were far too numerous to ignore.
Actually, Zend_View _does_ contain a helper for file upload input types, and has since before 1.0. However, there was neither enough time nor enough demand for a file upload form _element_ as we were moving towards 1.5. Additionally, a community contributor had written a proposal for a very nice upload abstraction class that would serve nicely as a backend for such an element — but there was not time to get it in for 1.5. To prevent duplication of effort, and to ensure we could deliver Zend_Form on schedule, file uploads simply slipped in priority. We _will_ be addressing uploads in 1.6, and the proposed solution is quite good, and will cover use cases such as upload progress.
Regarding your rant about what a framework _should_ deliver by specific version numbers, I respectfully disagree. Version numbers are arbitrary, and have no mapping to functionality delivered. Typically, a minor or major release version simply indicates new or stable functionality — not the _type_ of functionality delivered. Zend Framework tends to do things quite differently than other frameworks as we are a primarily community driven framework. While there is a small team of in-house developers, the bulk of code and contributions come from our community. As a result, components _you_ feel are “secondary” or “extraneous” are components that community contributors had immediate need for. To disparage them is to disparage the work of these contributors, which is unfair — unless you’re willing to step up and contribute yourself.
Matthew thank you for the reply!
I suppose what should or should not be included in a version 1, goes back to Wils’ comments on the philosophy of the framework. My thinking is version one includes the basics, bare bones, no frills functionality, (as to what’s considered basic…).
We’ll have to agree to disagree on this.
As to the community driven components - I was unaware that third parties had done all the work. To say they should be considered as secondary to “basic functionality” is not a disparage, but an opinion of development and management. As I stated before I shall no doubt become much more appreciative of these components when I get to the point in my application to use them.
If I happen to write anything that the community would find useful I shall indeed contribute, but as I’m still indoctrinating myself to the Zend way I find that most of my time is spent Googling and finding errors in my code.
Again, thank you for the reply and the hard work.
[...] seems to consist of ‘users’ rather than ‘doers’, people who would rather petition Zend to improve the software than submit a patch or create a new module. Open source projects, if they work well, are a bit [...]