title: Displaying images stored in the server using 'path/filename' stored in the database
body: <p>I just wanna ask if someone can explain to me why I cant display my images to the website that I'm creating. I stored the 'path/filename' in one of the columns in the database. While the image image is stored in the server.</p>
  
  <pre><code>&lt;?php foreach $data as $val{?&gt;
     &lt;img src="&lt;?php echo base_url();?&gt;&lt;?php echo $val-&gt;file;?&gt;"&gt;
  &lt;?php }?&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>$path = $_FILES["addFile"]["name"];
  $extension = pathinfo($path, PATHINFO_EXTENSION);
  
  $file_sc = 'uploads/screenshots/'.date("Ymdhms.").$extension;
  
  $new_name = date("Ymdhms").".".$extension;
  $target_dir = "./uploads/screenshots/";
  $target_file = $target_dir.$new_name;
  
  $type = $_FILES["addFile"]["type"];
  $allowed = array('image/jpeg', 'image/png', 'image/gif');
  
  if($_FILES["addFile"]["name"]){
      if(!in_array($type,$allowed)){
          echo 'File type is not allowed.';
      } else {
          move_uploaded_file($_FILES["addFile"]["tmp_name"],$target_file);
          $this-&gt;MyModel-&gt;add($file_sc);
      }
  </code></pre>
  
  <p>Model </p>
  
  <pre><code>function add_kudos($file_sc)
  {
    $query =  $this-&gt;db-&gt;query("insert into tbl_kudos(file) values('$file_sc');
  }
  </code></pre>
  
  <p>This is how it looks like in the database -> 'uploads/screenshots/20170224040231.jpg'</p>
  
  <p>The file name in the server ->20170224040231.jpg</p>
  
  <p>The image is not showing. Even if my url is correct.
  Can someone explain to me why it's like this? I am new to this.</p>