无法上传文件Codeigniter的任何时间

时间:2017-05-15 15:23:27

标签: php codeigniter-hmvc

移动到hmvc后,我的上传代码面临挑战。如果我设置jpg|jpeg它可以正常工作,但如果我设置为public function upload() { $customer_id = $this->session->userdata(user_id'); $time_uploaded = date("Y-m-d H:i:s"); $new_name = $string = str_replace(' ', '-', $time_uploaded); $directoryname = get_company_full_name($this->session->userdata('company_id')).'/payments'; if (!is_dir(FCPATH.'customer_documents/'.$directoryname)) { mkdir(FCPATH.'customer_documents/' . $directoryname, 0777, TRUE); } $config = [ 'upload_path' => FCPATH.'customer_documents/'.$directoryname, 'allowed_types' => 'jpg|png|pdf', 'max_size' => '1000000', 'file_name' => $new_name, 'overwrite' => TRUE, 'remove_spaces' => TRUE, 'encrypt_name' => FALSE ]; $this->load->library('upload'); $this->upload->initialize($config); if(!$this->upload->do_upload()) { $errors = array('errors' => $this->upload->display_errors()); $this->session->set_flashdata('errors',$errors['errors']); redirect('Payments/upload'); } else { $file_data = $this->upload->data(); $file_path = $new_name . $file_data['file_ext']; $file_path = $string = str_replace(' ', '-', $file_path); $time_uploaded = date("Y-m-d H:i:s"); $append = random_string('alpha',5); $txn_id = strtoupper($append).'.'.random_string('nozero',7); $data = array( 'customer_id' => $customer_id, 'time_uploaded' =>$time_uploaded, 'proof_path' => $file_path, 'txn_id' => $txn_id ); //Insert upload into database $this->proof->insert_file($data); $name_of_org = get_company_full_name($customer_id); $data['org_name'] = $name_of_org; $data['txn_id'] = $txn_id; $data['page'] = 'uploaded_proof'; //get email adresses for operating officers $email = $this->user->email(); //load email library $this->load->library('email'); $this->email->set_newline("\r\n"); foreach ($email as $row) { //set email information and content $this->email->from('ecofarmerbulksmsportal@econet.co.zw', 'Ecofarmer'); $this->email->to($row->email); $html_email = $this->load->view('email_view', $data, true); $this->email->subject(' Proof of Payment Upload '); $this->email->message($html_email); $this->email->send(); $message = 'New Bank Payment from ' .$name_of_org. ', is awaiting approval.'; send_message($message, $row->phone); } log_message('info', '***********************Customer with the ID: '.$this->session->userdata('company_id').' and name: '.get_company_full_name($this->session->userdata('company_id')).' uploaded proof of payment. The uploder phone number: '.$this->session->userdata('company_id').' The transaction ID: '.$txn_id.'***********************'); //isset Message $this->session->set_flashdata('success', 'You have successfully uploaded your proof of payment. The Operation Officer will give you feedback in 2 hrs'); //Redirect redirect('Payments/upload'); } } } 或任何类型,它会回复消息:

  

不允许您尝试上传的文件类型

以下是我的代码:

printf("my_int_value is %05d\n", my_int_value);

0 个答案:

没有答案