Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function uploadImage($newNamaFile, $dirUpload, $postName)
- {
- $config['upload_path'] = './resources/img/syarat_calon_mitra/'.$dirUpload;
- $config['allowed_types'] = 'jpg';
- $config['file_name'] = $newNamaFile;
- $config['overwrite'] = true;
- $config['max_size'] = 5120; // 1MB
- $this->load->library('upload', $config);
- if ($this->upload->do_upload($postName)) {
- return true;
- }else{
- $error = array('error' => $this->upload->display_errors());
- if(preg_match("/filetype/i", $error['error'])) {
- $data['error'] = 'Silahkan Pilih File .JPG';
- } else if(preg_match("/size/i", $error['error'])){
- $data['error'] = 'Max 5MB';
- }
- $this->form_validation->set_rules($postName, '', 'callback_cek_file2');
- }
- }
- function add(){
- if (!empty($_FILES['foto_ktp']['name'])) {
- $namaFileEKTP = $_FILES['foto_ktp']['name'];
- $namaSementaraEKTP = $_FILES['foto_ktp']['tmp_name'];
- $newNamaFileEKTP = $this->input->post('nomor_ktp') . $_FILES['foto_ktp']['name'];
- $file_extEKTP = pathinfo($namaFileEKTP, PATHINFO_EXTENSION);
- $dirUploadEKTP = "ektp/";
- $postNameEKTP = 'foto_ktp';
- $upload = $this->uploadImage($newNamaFileEKTP, $dirUploadEKTP, $postNameEKTP);
- if ($upload == 1) {
- $params['foto_ktp'] = $newNamaFileEKTP;
- }
- }
- if (!empty($_FILES['foto_kk']['name'])) {
- $namaFileKK = $_FILES['foto_kk']['name'];
- $namaSementaraKK = $_FILES['foto_kk']['tmp_name'];
- $newNamaFileKK = $this->input->post('nomor_ktp') . $_FILES['foto_kk']['name'];
- $file_ext = pathinfo($namaFileKK, PATHINFO_EXTENSION);
- $dirUploadKK = "kartu_keluarga/";
- $postNameKK = 'foto_kk';
- $upload = $this->uploadImage($newNamaFileKK, $dirUploadKK, $postNameKK);
- if ($upload == 1) {
- $params['foto_kk'] = $newNamaFileKK;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement