This is my code
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->addValidator('Extension', false,
array('extension' => 'exe, php, pl, js, html, htm', 'case' => false));
if (!$adapter->isValid())
{
return 'ERROR';
}
When I try to upload jpg or txt file I get ‘ERROR’ string. Looks like $adapter->isValid() return false. Should it return true?
What is wrong in my code?
The main problem is that you are trying to upload a
jpgortxtfile, but neither of those extensions are allowed in the list. You are only allowingexe,php,pl,js,html, orhtm.There is also a small problem with the way the extensions are set in the array having spaces between them. I inspected the values and ZF had the list of extensions you supplied, but every one except the first was preceded by a space.
Either of the following two options will work: