i an trying to upload a file and i need it to contain only letters, numbers and _
here is my code
$regex = new Zend_Validate_Regex('/^[a-zA-Z0-9_.]+$/i');
$regex->setMessages(array(
Zend_Validate_Regex::NOT_MATCH => 'NOT MATCH - File name can only contain letters, numbers and underscores',
Zend_Validate_Regex::INVALID => 'INVALID - File name can only contain letters, numbers and underscores',
Zend_Validate_Regex::ERROROUS => 'ERROR - File name can only contain letters, numbers and underscores'
));
$file = new Zend_Form_Element_File('file');
$file->setRequired(TRUE)
->setDestination($path)
->addValidator('Size', FALSE, array('min' => '10kB', 'max' => '100MB'))
->addValidator('Extension', FALSE, 'avi,mov,wmv,mpeg,flv,mpg,mp4')
->addValidator($regex)
->getValidator('Upload')->setMessage('No file selected');
$file->removeDecorator('DtDdWrapper');
$file->removeDecorator('HtmlTag');
$file->getDecorator('Label')->setTag(NULL);
i want this file to pass: test_test.jpeg
but not this one: test test.jpeg
the issue i am having is that even if the file name is OK the validator still throws the NOT_MATCH error
i even allowed . in case the file name is the entire file name string
any ideas?