您好我正在尝试使用以下表单代码上传 CSV 文件:
$this->widgetSchema ['file'] = new sfWidgetFormInputFile();
$this->setValidator('file', new sfValidatorFile(array(
'required' => true,
'path' => sfConfig::get('sf_upload_dir') . '/properties/csv',
'mime_categories' => array('csv' => array('text/csv', 'application/csv', 'application/excel', 'application/vnd.ms-excel', 'application/vnd.msexcel')),
'mime_types' => 'csv'
)));
在我的行动中,我有:
if($request->isMethod('post'))
{
$propertyCsvForm->bind($request->getParameter($propertyCsvForm->getName()), $request->getFiles($propertyCsvForm->getName()));
if($propertyCsvForm->isValid())
{
$this->getUser()->setFlash('success-csv', 'The CSV was successfully imported.');
} else {
$this->getUser()->setFlash('error-csv', 'The CSV could not be imported.');
}
}
当我尝试上传 CSV 时,我总是收到一个错误,即 mime 类型不正确
Invalid mime type (text/plain).
任何想法为什么?
谢谢