سؤال

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)))), 
             '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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top