Wednesday, May 24, 2017

Image resize when uploading Codeingniter 3

Image resize when uploading Codeingniter 3

We must enable file upload and fileinfo extensions.

 if(!empty($_FILES['image']['name'])){  
         $config['upload_path'] = './uploads/onlineadmission/';  
                     $config['allowed_types'] = 'gif|jpg|png';  
                     $config['max_size']   = '1500';  
                     $config['encrypt_name'] = TRUE;  
         $this->load->library('upload', $config);  
           if (!$this->upload->do_upload('image')){  
               $filerror = array('filerror' => $this->upload->display_errors('',''));  
               $this->data['filerror'] = $filerror;   
               $picture = '';             
           }  
           else{  
               $data_upload =$this->upload->data();  
               $picture = $data_upload['file_name'];  
                                    $configer = array(  
                                     'image_library'  => 'gd2',  
                                     'source_image'  => $data_upload['full_path'],  
                                     'maintain_ratio' => TRUE,  
                                     'width'      => 200,  
                                     'height'     => 200,  
                                    );  
                                    $this->image_lib->clear();  
                                    $this->image_lib->initialize($configer);  
                                    $this->image_lib->resize();  
           }  
       }else{  
         $picture = '';  
       }    

Sunday, May 7, 2017

Most easy way to get radio button value with Javascript


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<label for="gender">Gender: </label>
<input type="radio" name="genderS" value="1" checked="checked"/>Male
<input type="radio" name="genderS" value="2" />Female


<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x =  document.querySelector('input[name="genderS"]:checked').value;
    document.getElementById("demo").innerHTML = x;
}
</script>

Total Pageviews