2008年8月25日星期一

Re: [fw-mvc] Zend_Form_Element_File upload issues



On Mon, Aug 25, 2008 at 12:31 PM, Thomas Weidner <thomas.weidner@gmx.at> wrote:
Adam,

I can not speak for Zend_Form, but the file component itself, which has nothing to do with Zend_Form, moves a file if all validators attached to this file are ok. Zend_File_Transfer can not know about other validators from other components.

Fair enough.  But might it be possible to add, say, some sort of validation callback to the file transfer adapter so that it could be made aware (at runtime) of any larger processes it might be a part of?  For instance, a file validator that takes a Zend_Form object in its constructor and whose isValid() method simply checks if the rest of the form is valid (accounting, of course, for recursion problems)?
 


Also, when a user submits a form also attached files are uploaded. This is due to the HTTP protocol, where files are included in the form itself. There is no way of seperating them without seperating the data form and the upload form.

True, but the initial upload is temporary.  If you don't move the file to a permanent location (with, e.g., move_uploaded_file() or copy()), it's deleted after the script is processed.  My concern is that that temporary file is automatically moved to its final destination (assuming it passes validation), potentially causing data integrity issues if the upload is part of a larger process.
 


Normally I would propose to do all validations before and at last the file validations. Maybe you can arrange your validations.

Is it possible within Zend_Form to halt the entire form's validation process when one validator fails?  I.e., if the file element is at the end of the form and an earlier element isn't valid, don't fire the file element validators?
 

Second, the actual implementation of Zend_File_Transfer is not finished. It is the smallest summary of features we were able to deliver with 1.6 in this short time. It is far away from being finished, and you will see that there are several improvements already in the queue. 

Sounds good; my comments were only intended to serve as a part of that process.
 


To the manual: Filtering IS supported, but there are no filters available at the moment. In the next few weeks they will be available in the trunk. For example is there already a imagetype and a mimetype validator available in trunk which are not delivered with 1.6 due to feature freeze.

Ah...I misunderstood the wording in the manual; it says very clearly that this functionality is coming soon, but I took the first part ("At this time you cannot...") to mean that it wasn't even possible yet in the current release.  Good to know that it can be done!

Thanks for your feedback!
Adam

没有评论: