• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
upload a file

#1
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.