如何获取在 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 ??
);
}
最佳答案
1) 确保你的表单是多部分的。借助助手 form_open_multipart()
2) 使用上传库接收文件
3) 然后使用 $this->upload->data()
你得到包含文件信息的数组
Here完整的操作方法和官方文档
关于php - $_FILES ['file' ] ['name' ] 在 codeigniter 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14487672/