Welcome Guest, Not a member yet? Register   Sign In
Exceptions exceptions...
#6

(This post was last modified: 04-20-2020, 06:07 AM by Leo.)

No its not working. I've been hacking at it for a while but I can't get the picture error to display with other errors. I get other form field errors showing fine, but not my custom one, not showing at all.

PHP Code:
        $model = new ProductsModel();
        $validation Services::validation();
        $validation->setRules($model->validationRules);

        if(isset($_POST['submit'])) {

            $validation->withRequest($this->request)->run();

            //check image
            if(isset($_FILES['img_path'])) {
                $upload_config = (object)[
                    'width' => 280,
                    'height' => 200,
                    'dir' => WRITEPATH.'uploads',
                    'name' => 'img_path',
                    'multiple' => false,
                    'fit_or_cover' => 'cover',
                    'crop' => true,
                    'keepName' => false,
                    'returnOnlyFileName' => true
                
];
                $simpleImg = new SimpleImg($upload_config);
                try {
                    $new_images $simpleImg->upload();
                } catch (ImageException $e) {
                    //forInvalidImageCreate
                    if(substr($e066) === 'CodeIgniter\Images\Exceptions\ImageException: Your server does not') {
                        $validation->withRequest($this->request)->setError('img_path'lang('mixed.imageException', [], 'custom'));
                    }
                }
            }



And 
in my view file I have this:

$errors = \Config\Services::validation()->listErrors() ?? null;
echo 
$errors
You can see things I made with codeigniter here: itart.pro its not overly impressive as I have very little time to learn.
Reply


Messages In This Thread
Exceptions exceptions... - by Gary - 04-17-2020, 07:07 AM
RE: Exceptions exceptions... - by Leo - 04-19-2020, 02:08 PM
RE: Exceptions exceptions... - by Gary - 04-19-2020, 04:20 PM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 12:12 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 02:56 AM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 06:05 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 06:52 AM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 10:31 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 01:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB