我正在尝试将问题(泰卢固语和印地语等印度语)导入数据库。
要导入我们使用的是csv文件格式,但CSV文件不支持telugu文本,当我用telugu创建csv文件时,它将文本转换为“????????”。
我们可以使用.xlsx fomat ...导入问题吗? 这是我的控制器文件代码
public function importcsv()
{
try
{
if ($this->request->is('post'))
{
if(is_array($this->request->data['QuestionGroup']['group_name']))
{
if(strlen($this->request->data['Iequestion']['subject_id'])>0)
{
$fixed = array('Iequestion' => array('subject_id' => $this->request->data['Iequestion']['subject_id']));
$groupName=$this->request->data['QuestionGroup']['group_name'];
$filename = null;$extension=null;
$extension = pathinfo($this->request->data['Iequestion']['file']['name'],PATHINFO_EXTENSION);
if($extension=="csv")
{
if (!empty($this->request->data['Iequestion']['file']['tmp_name']) && is_uploaded_file($this->request->data['Iequestion']['file']['tmp_name']))
{
$filename = basename($this->request->data['Iequestion']['file']['name']);
move_uploaded_file($this->data['Iequestion']['file']['tmp_name'],APP . DS . 'tmp' . DS . 'csv' . DS . $filename);
$this->Iequestion->importCSV(APP . DS . 'tmp' . DS . 'csv' . DS . $filename,$fixed,$groupName,'QuestionGroup');
$this->Session->setFlash(__('Questions imported successfully'),'flash',array('alert'=>'success'));
return $this->redirect(array('action' => 'index'));
}
else
{
$this->Session->setFlash(__('File not uploaded'),'flash',array('alert'=>'danger'));
return $this->redirect(array('action' => 'index'));
}
}
else
{
$this->Session->setFlash(__('Only CSV File supported'),'flash',array('alert'=>'danger'));
return $this->redirect(array('action' => 'index'));
}
}
else
{
$this->Session->setFlash(__('Please Select Subject'),'flash',array('alert'=>'danger'));
return $this->redirect(array('action' => 'index'));
}
}
else
{
$this->Session->setFlash(__('Please Select any Group'),'flash',array('alert'=>'danger'));
return $this->redirect(array('action' => 'index'));
}
}
}
catch (Exception $e)
{
$this->Session->setFlash($e->getMessage(),'flash',array('alert'=>'danger'));
return $this->redirect(array('action' => 'index'));
}
}