Welcome Guest, Not a member yet? Register   Sign In
Error when try to upload empty file
#1

Hi family this error since yesterday trying to upload empty file inside my form
I think the problem is here inside the controller. Need help please.

Code:
$img = $this->request->getFile('userfile');
Inside the model
PHP Code:
// Validation
    protected $validationRules      = [
        'libelle_tag' => ['label' => 'Formu.tags.libelle_tag''rules' => 'required'],
        'userfile' => ['label' => 'Formu.tags.logo_tag''rules' => [
            'permit_empty',
            //'uploaded[userfile]',
            'is_image[userfile]',
            'mime_in[userfile,image/jpg,image/jpeg,image/gif,image/png,image/webp]',
            'max_size[userfile,50]',
            'max_dims[userfile,128,128]'
        ]]
    ]; 

Inside the controller
PHP Code:
$img $this->request->getFile('userfile');
            $fichier '';

            if (! $img->hasMoved() && $img->isValid()) {
                $newName $img->getRandomName();
                $img->move('./uploads/tags'$newName);

                $filepath FCPATH 'uploads/tags/' .$img->getName();

                $data = new \CodeIgniter\Files\File($filepath);
                $fichier $data->getBasename();
            

Inside the view 
PHP Code:
<?php $attributes = array('class' => 'uk-form uk-form-stacked uk-grid-small''uk-grid' => TRUE); ?>
 <?= form_open_multipart(current_url(), $attributes);  ?>
 <div class="uk-width-1-1@m uk-width-1-1@s">
 <?= form_label(lang('Formu.tags.libelle_tag'), 'libelle_tag', array('class' => 'uk-form-label')); ?> 
 <?php if($validation->hasError('libelle_tag')) echo '<span class="uk-label uk-label-danger">'.$validation->getError('libelle_tag').'</span>'?>
 <div class="uk-form-controls">
 <?= form_input('libelle_tag'set_value('libelle_tag'), 'class="uk-input"'?>
 </div>
 </div>
 
 <?php if($validation->hasError('userfile')) echo '<span class="uk-label uk-label-danger">'.$validation->getError('userfile').'</span>'?>
 <input type="file" name="userfile" size="20">
 
 <div class="uk-width-1-1">
 <button type="submit" class="uk-button uk-button-primary uk-float-right">
 <?= lang('Interface.ajouter'?>
 </button>
 </div>
 <?= form_close() ?>

Here is the error I have after submit form. I have data in my database but still have this message

[Image: ci_error_2023.png]
Forgive me i am a French Speaker (try ngatcharius on Social Network)
Reply
#2

no option "permit_empty" for files validation
Reply
#3

It is a bug in Kint. Upgrade CodeIgniter.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB