Hello!
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.
(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?)
Just thought I'd mention these things...what does everyone else think?
Thanks!
Adam
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.
(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?)
Just thought I'd mention these things...what does everyone else think?
Thanks!
Adam
没有评论:
发表评论