【发布时间】:2014-03-10 23:49:54
【问题描述】:
以下是我使用 codeigniter 框架在 mysql 数据库中上传文件的代码。 它有一些我无法找到的逻辑错误。请帮助我找到它。
function manage_prescription($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('laboratorist_login') != 1)
redirect(base_url() . 'index.php?login', 'refresh');
if ($param1 == 'create_diagnosis_report') {
$data['report_type'] = $this->input->post('report_type');
$data['document_type'] = $this->input->post('document_type');
move_uploaded_file($_FILES["userfile"]["tmp_name"], "uploads/diagnosis_report/" . $_FILES["userfile"]["name"]);
$data['file_name'] = $_POST["userfile"]["name"];
$data['prescription_id'] = $this->input->post('prescription_id');
$data['description'] = $this->input->post('description');
$data['timestamp'] = strtotime(date('Y-m-d') . ' ' . date('H:i:s'));
$data['laboratorist_id'] = $this->session->userdata('laboratorist_id');
$this->db->insert('diagnosis_report', $data);
$this->session->set_flashdata('flash_message', get_phrase('diagnosis_report_created'));
redirect(base_url() . 'index.php?laboratorist/manage_prescription/edit/' . $this->input->post('prescription_id'), 'refresh');
}
if ($param1 == 'delete_diagnosis_report') {
$this->db->where('diagnosis_report_id', $param2);
$this->db->delete('diagnosis_report');
$this->session->set_flashdata('flash_message', get_phrase('diagnosis_report_deleted'));
redirect(base_url() . 'index.php?laboratorist/manage_prescription/edit/' . $param3, 'refresh');
} else if ($param1 == 'edit') {
$page_data['edit_profile'] = $this->db->get_where('prescription', array(
'prescription_id' => $param2
))->result_array();
}
$page_data['page_name'] = 'manage_prescription';
$page_data['page_title'] = get_phrase('manage_prescription');
$page_data['prescriptions'] = $this->db->get('prescription')->result_array();
$this->load->view('index', $page_data);
}
当我运行此代码时,它不会出错。但是,它也不存储文件。而且它在数据库中显示file_name为NULL。
【问题讨论】:
-
您可以添加您的视图代码吗?
-
好的,我将添加我的查看代码@kumar_v
-
没有。编辑您的问题并添加。
-
无需作为新问题提出。您可以自行编辑此问题。
标签: php mysql file codeigniter upload