title: I want to upload image in codeigniter but my code does not work
body: <p><strong>view/image.php:</strong></p>
  
  <pre><code>&lt;form action="upload.php" method="post"&gt;
      &lt;h3&gt;Image Upload Form&lt;/h3&gt;
      &lt;input type="file" name="pic" tabindex="2" required&gt;
     &lt;input type="text" name="alt" placeholder="Image Alt Text" tabindex="1" 
     required&gt;
    &lt;button type="submit" id="img-submit" data-
     submit="Sending"&gt;Submit&lt;/button&gt;
        &lt;/form&gt;
  </code></pre>
  
  <p><strong>controller/upload.php:</strong></p>
  
  <pre><code>     public function __construct()
   {
    parent::__construct();
    $this-&gt;load-&gt;database();
     $this-&gt;load-&gt;helper('url');
    $this-&gt;load-&gt;helper('form');
    }
    function image()
   {
   $this-&gt;load-&gt;view('pages/image');
    }
   function upload()
      {
    $data = array(
      'image_url' =&gt; $this-&gt;input-&gt;$_FILES['pic']['name'],
      'alt' =&gt; $this-&gt;input-&gt;post('alt')
      )
  
     }
  </code></pre>
  
  <p><strong>models/upload_m.php:</strong></p>
  
  <pre><code> &lt;?php
   class pages_m extends CI_Model {
  
  function __construct()
  {
      parent::__construct();
  }
  function upload($data)
  { 
  return $this-&gt;db-&gt;insert('image',$data);
  
   }
  }
  ?&gt;
  </code></pre>
  
  <p>When I try to access the page through <code>localhost/codeigniter/index.php/pages/image</code> it shows <code>error 404 not found</code>. Also would be grateful if someone could check my code for possible mistakes I might have made? Thanks in advance!</p>