【发布时间】:2021-08-09 09:15:15
【问题描述】:
我正在使用 codeignitor 上传文件
但是当我对这些代码进行编码时,会显示 *Undefined index: *...
我做错了什么请给任何建议。
查看:
<form role="form" id="addNotic" action="<?php echo base_url() ?>upload" method="post" >
<?php echo form_open_multipart('upload/addNotification');?>
<input type="file" name="userfile" id="userfile" class="form-control required" />
<input type="submit" class="btn btn-primary" value="Submit" name="submit"/>
</form>
这是控制器:
function upload(){
$this->load->library('form_validation');
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->helper(array('form', 'url'));
if($this->upload->do_upload('userfile'))
{
$this->addNewNotification();// controler for view
$this->session->set_flashdata('success', 'New Notification created successfully');
}
else
{
$this->addNewNotification();
$this->session->set_flashdata('error', 'New Notification not created ');
}
}
显示错误
【问题讨论】:
-
写完整的错误信息。
-
哪个文件/层产生了错误?
标签: php error-handling codeigniter-3 file-handling