所以我正尝试使用codeigniter / php导入潜在客户的CSV格式文件。问题是Lead_name列容器中的行带有特殊字符(阿拉伯字母)。每当我将数据插入数据库时,我都会得到以下信息:اوكيل Ùوزية 请我需要帮助! 我在像这样的codeigniter中有数据库配置文件:
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'root',
'database' => 'crm_app',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
表单元素
<form id="myFormImport" method="post" id="import_csv" enctype="multipart/form-data">
<div class="form-group">
<label>Selectionner Fichier CSV</label>
<input type="file" name="csv_file" id="csv_file" required accept=".csv" />
</div>
<div class="modal-footer">
<button type="button" class="btn" data-dismiss="modal">Close</button>
<button type="submit" name="import_csv" class="btn btn-primary" id="import_csv_btn">Import CSV</button>
</div>
</form>
我甚至尝试将其添加到标题中
<?php header("Content-Type: text/html;charset=UTF-8");?>
请注意,我正在使用csvimport库!
似乎所有内容都设置为utf8_general ci,所以请帮助我找出问题所在!我会提供您需要我提供的一切!
如下所示,这是我在控制器中的导入脚本
public function ImportClient(){
$file_data = $this->csvimport->get_array($_FILES["csv_file"]["tmp_name"]);
foreach($file_data as $row)
{
$Clientinfo[] = array(
'NomClient' => $row["Nom Complet"],
'TelClient' => $row["Tel"],
'WilayaClient' => $row["Wilaya"],
'CommuneClient' => $row["Commune"],
'AdresseClient' => $row["Adresse"],
'TelevendeuseID' => 1,
'LivreurID' => 1,
'StatusLivraison' => 1,
'InvoiceID' => 10,
'StatusID' => 1,
'Source' => $row["Source"],
);
}
$result = $this->m->import($Clientinfo);
}
导入库
function __construct(){
parent:: __construct();
$this->load->model('leads_list', 'm');
$this->load->library('csvimport');
}