Welcome Guest, Not a member yet? Register   Sign In
upload a file
#1

(This post was last modified: 04-21-2020, 05:49 AM by kris2.)

Hello I need help to know how to updload an image.  I find example but nothing works either it is codeigniter 3 or it does not work for me

I created a form with
  <input type="file" name="acimage" />


On my controller I have ...
      $file = $this->request->getFile('acimage');
      if (! $file->isValid())
        {
                throw new RuntimeException($file->getErrorString().'('.$file->getError().')');
        }



On the line if (! $file->isValid())


I have the same kind of error

Call to a member function isValid() on null

same kind of error with
$file->getName();

not easy to write simple in black. Sorry

Is this page

https://makitweb.com/how-to-upload-file-in-codeigniter/

Still valid with codeigniter 4
Reply
#2

I found a solution


I changed in my view form_open by form_open_multipart

This is not very well explained in the example. They supposed to be obvious.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB