2016-02-22 150 views
0

嗨我試圖在Codeigniter中上傳.ini文件,但CI顯示我錯誤,該文件類型是不允許的。如何在codeigniter中上傳.ini文件?

我試圖把這個在mimes.php但沒有工作:

$mimes = array('ini' => 'application/octet-stream') 

我的代碼是:

public function index() 
{ 

$this->load->view('customer/upload/upload_ini', array('error' => ' ')); 
} 

function do_upload() 
{ 
    $config['upload_path'] = './uploads/'; 
    $config['allowed_types'] = 'ini'; 

    $this->load->library('upload', $config); 
    $this->upload->initialize($config); 


    if (! $this->upload->do_upload()) 
    { 
     $error = array('error' => $this->upload->display_errors()); 

     $this->load->view('customer/upload/upload_ini', $error); 
    } 
    else 
    { 
     $data = array('upload_data' => $this->upload->data()); 

     $this->load->view('customer/upload/upload_success', $data); 
    } 
} 
+0

這將幫助你http://stackoverflow.com/questions/19946892/uploading-ini-files-in-ci – Gopalakrishnan

+0

我想,已經@Gopal但它不工作 – Rajan

回答

1

該解決方案可以爲你工作,但它會 上傳所有文件類型,而不任何延期檢查,

$config['allowed_types'] = '*'; 

這個link可能會對y OU。

希望它會幫助你:)