以下是我使用codeigniter框架在mysql數據庫中上傳文件的代碼。 它有一些我無法找到的邏輯錯誤。請幫我找到它。文件不使用php 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 – user3116267
編輯您的問題並添加。 –