Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upload Proposal AKhir
- public function updatefileproposal_post()
- {
- $username = trim($this->post('username'));
- $id = $this->post('id');
- if ($username == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Username kosong.',
- ];
- } elseif ($id == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'ID Proposal kosong.',
- ];
- } elseif (empty($_FILES['file_pdf']['name'])) {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'File Proposal harus diisi.',
- ];
- } else {
- $jam = time();
- $config['file_name'] = 'Proposal_' . $username . '_' . $jam . '.pdf';
- $config['upload_path'] = './upload_file/proposal/';
- $config['allowed_types'] = 'pdf';
- $config['overwrite'] = true;
- $config['max_size'] = 0;
- $this->load->library('upload', $config);
- if (!$this->upload->do_upload('file_pdf')) {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'File harus PDF.',
- ];
- } else {
- $data = array(
- 'propose_proposal' => $this->upload->file_name,
- 'propose_update' => date('Y-m-d H:i:s'),
- );
- $this->db->where('propose_id', $id);
- $this->db->update('lemlit_propose', $data);
- $response = [
- 'resp_error' => false,
- 'resp_msg' => 'Proposal Berhasil di Simpan.',
- ];
- }
- }
- $this->response($response, 200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement