Hi I'm trying to upload a CSV file using the following form code:
$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'
)));
In my action I have:
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.');
}
}
When I try to upload a CSV I always get an error, which is the mime type is incorrect
Invalid mime type (text/plain).
Any ideas why?
Thanks