(on Monday, 25 August 2008, 11:50 AM -0500):
> Just started using Zend_Form_Element_File on one of my file upload forms, and I
> noticed a couple of things that concern me a bit. (I apologize if these have
> already been mentioned; I couldn't find them in the bug tracker, but I figured
> I'd ask here first.)
>
> There does not seem to be any way to keep the file element from moving the
> uploaded file to its target destination in the event of certain kinds of
> errors. There are two error situations I'm most concerned with:
>
> (1) Suppose that the file element isValid(), but the other elements in the form
> are not. The file still gets uploaded to the server, correct? To me, this
> doesn't seem like a good idea. Consider a form which corresponds to a record
> in a database table. If the user submits the form and three values are valid
> while the remaining six are not, typically we don't write anything at all to
> the database (not even the valid values). Now, what if one of those valid
> elements is a file instead? Personally I think the file should not be
> uploaded, since none of the other valid values get stored either.
Could you place a feature request for this?
One issue here is that one of the validators for a file upload is, well,
an upload validator: ensuring that there were no errors. The element
cannot be said to validate unless this is true. We could potentially
create a flag that says, "do not perform the upload validation", but
this could lead to other issues later if it cannot actually perform the
upload -- so we need to go about this carefully.
> (2) What happens when someone uploads a file that results in a name conflict in
> the destination folder? For instance, if my destination folder already
> contains a file called "my_upload.txt" and a user uploads another file called
> "my_upload.txt", currently the existing file simply gets overwritten. Is there
> a way to keep this from happening? Seems like it could be built into either a
> validator or a filter; the validator would simply block conflicting files from
> upload, while the filter would somehow change the name of the new file so that
> it no longer conflicted (of course, according to the manual, this kind of
> filtering is not yet supported, right?)
This is an issue for a filter, and we have built in support for filters
-- but not shipped any yet. Thomas is already working on these, but
perhaps you could place a feature request for this specific filter as
well, so you can track it.
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论