Welcome Guest, Not a member yet? Register   Sign In
Validation uploaded files not work with redirect back?

I've tried to validate the input of a form then use redirect()->back() but the validator doesn't work validating the upload file. I've checked with getErrors() function but its empty.
How to solve that issue? I really appreciate for your help and response.

PHP Code:
public function index($id_customer)
        $session session();
        $data['customer'] = $this->CustomerModel->getCustomerById($id_customer);
        $data['validation'] = \Config\Services::validation();

        return view('form'$data);

public function 
        $session session();

        $rules = [
             // I don't know why if I comment 'images' rule the validation goes well
            'images' => [
                'label' => 'Images',
                'rules' => 'uploaded[images.0]|max_size[images,4096]|is_image[images]|mime_in[images,image/gif,image/jpeg,image/png]',
                'errors' => [
                    'uploaded' => '{field} field is required',
                    'is_image' => 'Uploaded files are not Image files.',
                    'max_size' => 'Allowed maximum size is 4MB',
                    'mime_in' => 'The Image type is not allowed. Allowed types : gif, jpeg, png'
            'notes' => [
                'label' => 'Notes',
                'rules' => 'required',
                'errors' => [
                    'required' => '{field} field is required'

        if (!$this->validate($rules)) {
            // Validator with rules
            $validation = \Config\Services::validation();
            return redirect()->back()->withInput()->with('validation'$validation); //redirect to Index function

I think you need to specify images.0 for all the images fields.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB