PHP

codeigniter-file-upload-required-validation

We write for validation:: $this->form_validation->set_rules(‘name’, ‘Name’, ‘trim|required’); $this->form_validation->set_rules(‘code’, ‘Code’, ‘trim|required’); $this->form_validation->set_rules(‘userfile’, ‘Document’, ‘required’); Now have to write like, : $this->form_validation->set_rules(‘name’, ‘Name’, ‘trim|required’); $this->form_validation->set_rules(‘code’, [...]

Check if file is csv type

//File type Checking: $mimes = array(‘application/vnd.ms-excel’,’text/plain’,’text/csv’,’text/tsv’); if(!in_array($_FILES[‘sf_admin_file’][‘type’],$mimes)) {             $this->form_validation->set_rules(‘sf_admin_file’, ‘Document’, ‘required’); } [...]