我已經寫了一些代碼來上傳使用PHP在MySQL數據庫中的文件。 以下是我上傳文件的代碼。文件上傳錯誤使用php
$data['report_type'] = $this->input->post('report_type');
$data['document_type'] = $this->input->post('document_type');
$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');
move_uploaded_file($_FILES["userfile"]["tmp_name"], "uploads/diagnosis_report/" . $_FILES["userfile"]["name"]);
$data['file_name'] = $_FILES["userfile"]["name"];
$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');
每當我嘗試上傳任何文件。它給出了一個錯誤,因爲
Column 'file_name' cannot be null
INSERT INTO
diagnosis_report
(report_type
,document_type
,prescription_id
,description
,timestamp
,laboratorist_id
,file_name
) VALUES (0, 0, 0, 0, 1392206996, '1', NULL)
我的代碼有什麼問題?
'INSERT INTO diagnosis_report(REPORT_TYPE,DOCUMENT_TYPE,prescription_id,描述,timestamp,laboratorist_id,file_name)VALUES(0,0,0,1392206996,'1','') –
是否使用codeigniter框架 – Jenz
是@Jenz!我正在使用Codeigniter框架! – user3116267