I am using Symfony 1.4 and Propel as ORM. I have created a form using the Symfony Form, which contains some text inputs and file upload elements. The form structure,
$this->setWidgets(array(
'name' =>new sfWidgetFormInput(),
'mobile' =>new sfWidgetFormInput(),
'resume' =>new sfWidgetFormInputFile()
));
$mime_array=array("application/pdf","application/msword");
$this->setValidators(array(
'name' =>new sfValidatorString(array('required' => true)),
'mobile' =>new sfValidatorAnd(array(new sfValidatorNumber(),new sfValidatorString(array('required' => true, 'min_length' => 10, 'max_length' => 10)))),
开发者_如何学JAVA 'resume' =>new sfValidatorFile(array('mime_types' => $mime_array))
));
But the file upload Validation not working for Ms Word files, but works for PDF files(as user can upload PDF or Ms Word Document).
Not totally sure but I think new office 2007 word docs require a different mime type:
application/vnd.openxmlformats-officedocument.wordprocessingml.document
(add that to your array to test)
I believe the other one is for older word versions.
Here's some related reading: http://www.vladville.com/2007/04/office-2007-mime-types-for-apache.html
精彩评论