1

我使用 Symfony 1.4 和 Propel 作为 ORM。我使用 Symfony 表单创建了一个表单,其中包含一些文本输入和文件上传元素。形式结构,

$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))
    ));

但是文件上传验证不适用于 Ms Word 文件,但适用于 PDF 文件(因为用户可以上传 PDF 或 Ms Word 文档)。

4

1 回答 1

2

不完全确定,但我认为新的 office 2007 word 文档需要不同的 mime 类型:

application/vnd.openxmlformats-officedocument.wordprocessingml.document

(将其添加到您的数组中进行测试)

我相信另一个是用于较旧的单词版本。

这里有一些相关的阅读:http ://www.vladville.com/2007/04/office-2007-mime-types-for-apache.html

于 2011-01-10T12:11:01.277 回答