2013-01-23 32 views
3

如何獲取在codeigniter中上傳的文件的文件名。我們將輸入字段的值作爲$ this-> input-> post('name'),但是我如何獲得從窗體上傳的文件的名稱?

public function create(){ 

     //getting all the POST data in $data array 
     $data = array('title' => $this->input->post('title') , 
       'content' => $this->input->post('content'), 
       'filename' => ?? HOW ?? 
     ); 
} 
+2

CI [用戶指南](http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html)作爲所有信息。您需要使用'$ this-> upload-> data()'.. – user1190992

+0

請將您的表單放在視圖中。 – 2013-01-23 21:37:02

回答

2

1)確保你的窗體是多部分。有了幫手其form_open_multipart()

2)使用上傳庫接收文件

3),然後用$this->upload->data()你得到的文件信息陣列

Here充滿了如何和官方文件

0
public function create(){ 

     //getting all the POST data in $data array. 
     $data = array('title' => $this->input->post('title') , 
       'content' => $this->input->post('content'), 
       'filename' => $_FILES["file"]["name"] 
     ); 
} 
相關問題