Validação de upload de arquivo no Codeigniter
Estou tentando validar o upload de arquivos para upload de imagens, mas ele não está recebendo a validação como outros campos. estou usandoForm_Validation.php
processo para validação.
Matriz de upload de imagem:
array(
'field'=>'image',
'label' => 'Image',
'rules' => 'required'
)
quando tento fazer o upload da imagem, ela não responde como é necessário, etc. Também quero validá-la para.jpg
etc e "como definir o valor do arquivo no arquivo incorreto, como em vez de.jpg
tentamos fazer upload do.pdf
"como definimos o valor do campo de entradaset_value('field name')
etc.
Verifiquei muitas perguntas e também tentei usar o método de chamada, mas não consegui corrigi-lo.
ATUALIZAR:
Forneça resposta detalhada com exemplo de código. Por favor, use o formulário form_validation.php no exemplo e também forneça o código de exemplo de retorno de chamada, para que eu possa ler / aprender e modificá-lo adequadamente.
ATUALIZAÇÃO 2:
public function Task()
{
if ($this->form_validation->run('Sub_Admin/task') == FALSE) {
$this->data['Task'] = $this->bm->get_usr();
$data['title'] = "Add New Task";
$this->load->view('Subadmin/header',$data);
$this->load->view('Subadmin/nav');
$this->load->view('Subadmin/sidebar');
$this->load->view('Subadmin/task', $this->data);
$this->load->view('Subadmin/footer');
}
else
{
$config['upload_path'] = './taskimages/'; //The path where the image will be save
$config['allowed_types'] = 'gif|jpg|png'; //Images extensions accepted
$config['max_size'] ='10048'; //The max size of the image in kb's
//$config['max_width'] = '1024'; //The max of the images width in px
//$config['max_height'] = '768'; //The max of the images height in px
$config['overwrite'] = FALSE; //If exists an image with the same name it will overwrite. Set to false if don't want to overwrite
$this->load->library('upload', $config); //Load the upload CI library
$this->load->initialize($config);
$this->upload->do_upload('task');
$file_info = $this->upload->data();
$file_name = $file_info['file_name'];
$data = array(
'Job_Title' => $this->input->post('jtitle'),
'Priority' => $this->input->post('jnature'),
'Assignee' => $this->input->post('assigne'),
'Employee_Name' => $this->input->post('assignto'),
'Due_Date' => $this->input->post('ddate'),
'Reminder' => $this->input->post('reminder'),
'Task_Image' => $file_name,
);
$this->bm->add_task($data);
}
}
Eu já estou usando a classe de upload de IC, mas ele não está funcionando, e agora quero validar a imagem / arquivo do lado do form_validation.