title: File_exists function is not working
body: <p>Since the problem was on file_exists() and it seems that the function should goes to the root directory, so when you determine the file location on the <code>file_exists</code> function you declare it with the base url because it only tests the file location from the server not from a url : </p>
  
  <h2>Wrong Code</h2>
  
  <pre><code>    $dir = base_url()."assets/produits/";
  
      foreach ($rows as $row) {
          $nom = $row-&gt;nShape;
          $type = array(".jpeg", ".jpg");
  
          foreach ($type as $ext) {
              echo "&lt;br&gt;I'm in the foreach loop &lt;br&gt;";
              $file_name = $dir . $nom . $ext;
  
              if (file_exists($file_name)) {
                 echo "I'm in the file_exists function&lt;br&gt;";
                 $img_src = $file_name;
              } else {
                  echo "I'm in the else statement &lt;br&gt;";
                  echo $file_name."\n";
                  $img_src = $dir . "none.png";
              }
          }
      }
  </code></pre>
  
  <p>The problem is that the full name is there but it always treat it as it doesnot exists, I've made some echos to check did code reaches and here's a screeenshot : <a href="https://i.stack.imgur.com/DR4J3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DR4J3.png" alt="Screen shot of the problem"></a></p>
  
  <p>Knowing that the <code>http://localhost/dedax_new/assets/produits/2052.jpeg</code>exists in the server.<br></p>
  
  <h2>Solution :</h2>
  
  <pre><code>// set the default to the no find image
  $img_src = base_url() . "assets/produits/none.png";
  
  foreach ($rows as $row) {
      $nom = $row-&gt;nShape;
      $type = array(".jpeg", ".jpg");
  
      foreach ($type as $ext) {
          $file_name =  $nom . $ext;
  
          if (file_exists("./assets/produits/".$file_name)) {
             $img_src = base_url() . 'assets/produits/'.$file_name;;
             // we found a file that exists 'get out of dodge'
             break;
          }
      }
  </code></pre>
  
  <p>Thanks to all contributors in advance.</p>