title: Retrieve Images From Folder with Codeigniter
body: <p>My teacher,he was uploading and retrieving images from folder with ID recognition. It works with database.</p>
  
  <ol>
  <li>So, when we upload an image, it will be stored in a folder with it's name changing automatically with ID.</li>
  <li>Example: The upload form must be on "yourwebsite.com/yourpages/3144242" so the image will be stored as "3144242" and blablabla the same for other pages with ID</li>
  </ol>
  
  <p>This is how he upload and retrieve it</p>
  
  
  
  <pre><code> &lt;?php
      $ff = './assets/images/kegiatan/'.$_SESSION['idkeg'].'.jpg';
        if( file_exists( $ff ) ) {
            &lt;img src="&lt;?= base_url()?&gt;assets/images/kegiatan/&lt;?=$_SESSION['idkeg']?&gt;.jpg" /&gt;
   &lt;?php
         }
   ?&gt;
  </code></pre>
  
  <p>Retrieve images part:</p>
  
  <pre><code>      if( file_exists( $ff ) ) {
            &lt;img src="&lt;?= base_url()?&gt;assets/images/kegiatan/&lt;?=$_SESSION['idkeg']?&gt;.jpg" /&gt;
   &lt;?php
         }
   ?&gt;
  </code></pre>
  
  <p>However, I change it a bit so I don't have to use a database and $_SESSION things. With this:</p>
  
  <pre><code>&lt;?php
     $ff = './assets/images/kegiatan/'.$this-&gt;input-&gt;post('img_name').'.jpg';
   ?&gt;
    &lt;form id="form" class="kart" action="&lt;?= base_url()?&gt;gallery/upload2" method="post" enctype="multipart/form-data"&gt;
      &lt;div class="form-group"&gt;
        &lt;input type="text" class="form-control" name="img_name" required="required"&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
         &lt;input type="file" class="form-control" name="foto"&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;button type="submit" class="btn btn-common" value="Update"&gt;&lt;i class="fa fa-upload fa-2x"&gt; Upload&lt;/i&gt;&lt;/button&gt;
      &lt;/div&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>It works uploading images into folder "kegiatan" (means activity) with simply write the names of images in a form. The img_name that you have input, now become the name of that image.</p>
  
  <p>Now I have a little problem to retrieve that images. How?</p>