Migrating your Script using Zend_File_Transfer from 1.6.1 to a newer release
- Posted by thomasw at 13:01:16 // //
- Announcements, Filter, Other
Hy interested ones,
most of you know this already. But it seems that users tend not to read migration notes so I will say it once more here.
When you are using Zend_File_Transfer in conjunction with validations you will have to note that the API has changed.
I added a $breakChainOnFailure parameter which allows to break the validation chain for further validators if a validation error occurs.
To give you an example:
// Example for 1.6.1 or earlier
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addValidator('FilesSize', array('1B', '100kB'));
// Same example for 1.6.2 and newer
// Note the added boolean false
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addValidator('FilesSize', false, array('1B', '100kB'));
So as conclusio for you:
If you have to migrate old scripts simply add a boolean false after the validator name.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
Add comment
Fill out the form below to add your own comments

Sunday, October 12, 2008 - 20:32:10
Hello, there is an error in the Upload filter class.
It tryes work with internal $files array like with $_FILES array and tries find
$files[filename][’tmp_dir’] which of course does not exists
So with this bug in 1.6.0 and 1.6.1 upload does not wors.
I have now write upload part on pure PHP in older manner because there is only one solution - patch filter
Sunday, October 12, 2008 - 22:05:27
You should use an unchanged release of ZF.
Within ZF the key ‘tmp_dir’ is wether used nor available, wether within 1.6.0 or any following release.
Also a ‘UploadFilter’ class does not exist.
I can’t comment code which is not from me nor from Zend.
Please ask at the place where you got your patched version of ZF for help about their code.
Monday, October 13, 2008 - 11:56:27
my task is - make setDestination AFTER data processing
So after $form->isValid() setDestination() does not work.
I’ve create two forms to process data because of this things - first - without upload element and second with it.
This method works but looks bad :)
Monday, October 13, 2008 - 14:42:19
These are two different things…
You can not change settings after the code has run through. This would be like changing properties of an object after it has been closed… completly useless.
But changing setDestination after isValid() works, because the file is processed when you call receive(), and not before.
Still, this could lead to the problem that your receive throws an error when the destination path is not valid.
Thursday, October 16, 2008 - 17:09:27
Hello,
This is probably the wrong place to post this, but I’m new to ZF and not sure where to file such findings. If you could point me in the appropriate direction I would be most grateful.
I just upgraded from 1.6.0 to 1.6.2 and discovered that if I use setDestination without addFilter on a Zend_Form_Element_File I get these errors when I call isValid on the form:
Undefined index: filters in Zend/File/Transfer/Adapter/Abstract.php on line 796
Unsupported operand types in Zend/File/Transfer/Adapter/Abstract.php on line 796
Surely adding a filter is not mandatory?
Many thanks,
Shaun
Thursday, October 16, 2008 - 17:31:26
Best is always to subscribe and ask in the ZF mailinglists. fw-general@lists.zend.com
For this problem was already, 2 times, a solution offered in the list.
Please understand, that I can not solve problems and issues within my blog. This is the false media for such cases. :-)
Thursday, October 16, 2008 - 17:38:21
Thanks for the response. I understand. Will subscribe to the list. Cheers,
Shaun