2015-10-22 423 views
2

Im做LOAD DATA INFILE我有了這個代碼笨3,LOAD DATA INFILE,fcpath

move_uploaded_file($file_temp,"uploads/master_listing/".$file_name); 

$file_path = FCPATH.'/uploads/master_listing/'.$file_name; 

$this->db->query("LOAD DATA LOCAL INFILE '".$file_path."' 
    INTO TABLE fsi_temp_newmasterlist 
    FIELDS TERMINATED BY ',' 
    LINES TERMINATED BY '\\n' 
    IGNORE 1 LINES 
    (SEQUENCENUMBER,NAME,ADDRESS,PICKUPDATE,ENCODERNO,BARCODEVALUE,REMARKS,CLIENT,PROD) 
"); 

我不知道什麼是錯在代碼中,我得到了錯誤Can't find file

這裏是我的文件位置myfolder/uploads/master_listing/

我的CSV文件的SEQUENCENUMBER,NAME,ADDRESS,PICKUPDATE,ENCODERNO,BARCODEVALUE,REMARKS,CLIENT,PROD

我真的需要幫助的表頭..在此先感謝。

+0

'回聲$ file_path'和檢查 –

+0

我得到這個C:\ xampp5.5 \ htdocs中\ joel_fsi \ fsi2 /上傳/ master_listing/testfileupload.csv –

+0

我已經更換位置真正的路徑,但它仍然給我錯誤LOAD DATA LOCAL INFILE'C:\ xampp5.5 \ htdocs \ joel_fsi \ fsi2 \ uploads \ master_listing \ testfileupload.csv' –

回答

2

使用本

$new_name = str_replace("\\","/",$file_path) 

後更換

C:/xampp5.5/htdocs/joel_fsi/fsi2/uploads/master_listing/testfileupload.csv 

在你的代碼

C:\xampp5.5\htdocs\joel_fsi\fsi2/uploads/master_listing/testfileupload.csv 

他們是衝突\/

看一看這一Codeigniter path functions definitions

+0

$ new_name = str_replace(「\」,「/」,$ file_path)是錯誤 –

+0

對不起,小錯誤現在它的工作 –

+0

'str_replace'應該是''\\「' –